From 6c5e7929b6308b158ba2e6f401352631c4bfbe20 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 3 May 2023 14:04:58 -0600 Subject: [PATCH] More tweaks --- core/models/config.py | 1 + takahe/__init__.py | 2 +- takahe/urls.py | 11 ++++++++--- templates/_footer.html | 7 ++++--- templates/admin/announcement_create.html | 2 +- templates/admin/announcement_edit.html | 2 +- templates/admin/announcements.html | 2 +- templates/admin/{base.html => base_main.html} | 0 templates/admin/domain_create.html | 2 +- templates/admin/domain_delete.html | 2 +- templates/admin/domain_edit.html | 2 +- templates/admin/domains.html | 2 +- templates/admin/emoji.html | 2 +- templates/admin/emoji_create.html | 2 +- templates/admin/federation.html | 2 +- templates/admin/federation_edit.html | 2 +- templates/admin/hashtag_edit.html | 2 +- templates/admin/hashtags.html | 2 +- templates/admin/identities.html | 2 +- templates/admin/identity_edit.html | 2 +- templates/admin/invite_create.html | 2 +- templates/admin/invite_view.html | 2 +- templates/admin/invites.html | 2 +- templates/admin/report_view.html | 2 +- templates/admin/reports.html | 2 +- templates/admin/settings.html | 2 +- templates/admin/stator.html | 2 +- templates/admin/user_edit.html | 2 +- templates/admin/users.html | 2 +- users/models/identity.py | 4 ++-- users/views/admin/identities.py | 3 ++- users/views/admin/settings.py | 6 ++++++ users/views/settings/profile.py | 3 +++ users/views/settings/settings_page.py | 2 ++ 34 files changed, 53 insertions(+), 34 deletions(-) rename templates/admin/{base.html => base_main.html} (100%) diff --git a/core/models/config.py b/core/models/config.py index 4f88365..48eda4e 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -247,6 +247,7 @@ class Config(models.Model): policy_terms: str = "" policy_privacy: str = "" policy_rules: str = "" + policy_issues: str = "" signup_allowed: bool = True signup_text: str = "" diff --git a/takahe/__init__.py b/takahe/__init__.py index 777f190..8ea1e34 100644 --- a/takahe/__init__.py +++ b/takahe/__init__.py @@ -1 +1 @@ -__version__ = "0.8.0" +__version__ = "0.9.0-dev" diff --git a/takahe/urls.py b/takahe/urls.py index 8577933..6ee5444 100644 --- a/takahe/urls.py +++ b/takahe/urls.py @@ -266,17 +266,22 @@ urlpatterns = [ path( "pages/privacy/", core.FlatPage.as_view(title="Privacy Policy", config_option="policy_privacy"), - name="privacy", + name="policy_privacy", ), path( "pages/terms/", core.FlatPage.as_view(title="Terms of Service", config_option="policy_terms"), - name="terms", + name="policy_terms", ), path( "pages/rules/", core.FlatPage.as_view(title="Server Rules", config_option="policy_rules"), - name="rules", + name="policy_rules", + ), + path( + "pages/issues/", + core.FlatPage.as_view(title="Report a Problem", config_option="policy_issues"), + name="policy_issues", ), # Annoucements path("announcements//dismiss/", announcements.AnnouncementDismiss.as_view()), diff --git a/templates/_footer.html b/templates/_footer.html index d5526d3..7f2ac32 100644 --- a/templates/_footer.html +++ b/templates/_footer.html @@ -1,7 +1,8 @@ diff --git a/templates/admin/announcement_create.html b/templates/admin/announcement_create.html index 079b6d9..9430760 100644 --- a/templates/admin/announcement_create.html +++ b/templates/admin/announcement_create.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Create Announcement{% endblock %} diff --git a/templates/admin/announcement_edit.html b/templates/admin/announcement_edit.html index a209197..7d60b9a 100644 --- a/templates/admin/announcement_edit.html +++ b/templates/admin/announcement_edit.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Announcement #{{ announcement.pk }}{% endblock %} diff --git a/templates/admin/announcements.html b/templates/admin/announcements.html index 9aa84cd..11dc695 100644 --- a/templates/admin/announcements.html +++ b/templates/admin/announcements.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Announcements{% endblock %} diff --git a/templates/admin/base.html b/templates/admin/base_main.html similarity index 100% rename from templates/admin/base.html rename to templates/admin/base_main.html diff --git a/templates/admin/domain_create.html b/templates/admin/domain_create.html index f84d724..6f1acdf 100644 --- a/templates/admin/domain_create.html +++ b/templates/admin/domain_create.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block title %}Add Domain - Admin{% endblock %} diff --git a/templates/admin/domain_delete.html b/templates/admin/domain_delete.html index 1fa1808..78a61f2 100644 --- a/templates/admin/domain_delete.html +++ b/templates/admin/domain_delete.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block title %}Delete {{ domain.domain }} - Admin{% endblock %} diff --git a/templates/admin/domain_edit.html b/templates/admin/domain_edit.html index 0c4f955..d030370 100644 --- a/templates/admin/domain_edit.html +++ b/templates/admin/domain_edit.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ domain.domain }}{% endblock %} diff --git a/templates/admin/domains.html b/templates/admin/domains.html index 1fa9751..316c395 100644 --- a/templates/admin/domains.html +++ b/templates/admin/domains.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Domains{% endblock %} diff --git a/templates/admin/emoji.html b/templates/admin/emoji.html index 44f64d5..077aadc 100644 --- a/templates/admin/emoji.html +++ b/templates/admin/emoji.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% load activity_tags %} {% block subtitle %}Emoji{% endblock %} diff --git a/templates/admin/emoji_create.html b/templates/admin/emoji_create.html index 7051b00..f2c528e 100644 --- a/templates/admin/emoji_create.html +++ b/templates/admin/emoji_create.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ emoji.shortcode }}{% endblock %} diff --git a/templates/admin/federation.html b/templates/admin/federation.html index ddbc91d..44ac896 100644 --- a/templates/admin/federation.html +++ b/templates/admin/federation.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% load activity_tags %} {% block subtitle %}Federation{% endblock %} diff --git a/templates/admin/federation_edit.html b/templates/admin/federation_edit.html index a9e3d6d..c32d1cc 100644 --- a/templates/admin/federation_edit.html +++ b/templates/admin/federation_edit.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ domain.domain }}{% endblock %} diff --git a/templates/admin/hashtag_edit.html b/templates/admin/hashtag_edit.html index 0a0ed48..1be912f 100644 --- a/templates/admin/hashtag_edit.html +++ b/templates/admin/hashtag_edit.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ hashtag.hashtag }}{% endblock %} diff --git a/templates/admin/hashtags.html b/templates/admin/hashtags.html index 5d0d443..910e527 100644 --- a/templates/admin/hashtags.html +++ b/templates/admin/hashtags.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Hashtags{% endblock %} diff --git a/templates/admin/identities.html b/templates/admin/identities.html index 11bd525..62c87e3 100644 --- a/templates/admin/identities.html +++ b/templates/admin/identities.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% load activity_tags %} {% block subtitle %}Identities{% endblock %} diff --git a/templates/admin/identity_edit.html b/templates/admin/identity_edit.html index 7a50409..2f9fa28 100644 --- a/templates/admin/identity_edit.html +++ b/templates/admin/identity_edit.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ identity.name_or_handle }}{% endblock %} diff --git a/templates/admin/invite_create.html b/templates/admin/invite_create.html index 02e4b15..3dfb2a5 100644 --- a/templates/admin/invite_create.html +++ b/templates/admin/invite_create.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Create Invite{% endblock %} diff --git a/templates/admin/invite_view.html b/templates/admin/invite_view.html index 1489fe7..b5ded54 100644 --- a/templates/admin/invite_view.html +++ b/templates/admin/invite_view.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}View Invite{% endblock %} diff --git a/templates/admin/invites.html b/templates/admin/invites.html index f5f2cbf..fcfbe74 100644 --- a/templates/admin/invites.html +++ b/templates/admin/invites.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% load activity_tags %} {% block subtitle %}Invites{% endblock %} diff --git a/templates/admin/report_view.html b/templates/admin/report_view.html index 3ca87be..71c24d1 100644 --- a/templates/admin/report_view.html +++ b/templates/admin/report_view.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Report {{ report.pk }}{% endblock %} diff --git a/templates/admin/reports.html b/templates/admin/reports.html index f70cbcb..b96a2da 100644 --- a/templates/admin/reports.html +++ b/templates/admin/reports.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% load activity_tags %} {% block subtitle %}Reports{% endblock %} diff --git a/templates/admin/settings.html b/templates/admin/settings.html index 10326f0..d2baeea 100644 --- a/templates/admin/settings.html +++ b/templates/admin/settings.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ section.title }}{% endblock %} diff --git a/templates/admin/stator.html b/templates/admin/stator.html index d93b0f8..94a04a5 100644 --- a/templates/admin/stator.html +++ b/templates/admin/stator.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}Stator{% endblock %} diff --git a/templates/admin/user_edit.html b/templates/admin/user_edit.html index 130fa85..3f43022 100644 --- a/templates/admin/user_edit.html +++ b/templates/admin/user_edit.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% block subtitle %}{{ editing_user.email }}{% endblock %} diff --git a/templates/admin/users.html b/templates/admin/users.html index 9472b84..da65c79 100644 --- a/templates/admin/users.html +++ b/templates/admin/users.html @@ -1,4 +1,4 @@ -{% extends "admin/base.html" %} +{% extends "admin/base_main.html" %} {% load activity_tags %} {% block subtitle %}Users{% endblock %} diff --git a/users/models/identity.py b/users/models/identity.py index d1dfa22..f8daad2 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -624,12 +624,12 @@ class Identity(StatorModel): from activities.models.post import Post, PostStates Post.transition_perform_queryset(self.posts, PostStates.deleted) - # Move ourselves to deleted - self.transition_perform(IdentityStates.deleted) # Remove all users from ourselves and mark deletion date self.users.set([]) self.deleted = timezone.now() self.save() + # Move ourselves to deleted + self.transition_perform(IdentityStates.deleted) ### Actor/Webfinger fetching ### diff --git a/users/views/admin/identities.py b/users/views/admin/identities.py index 50b9f7e..9292ab9 100644 --- a/users/views/admin/identities.py +++ b/users/views/admin/identities.py @@ -26,7 +26,8 @@ class IdentitiesRoot(ListView): def get_queryset(self): identities = ( - Identity.objects.annotate(num_users=models.Count("users")) + Identity.objects.not_deleted() + .annotate(num_users=models.Count("users")) .annotate(followers_count=models.Count("inbound_follows")) .order_by("created") ) diff --git a/users/views/admin/settings.py b/users/views/admin/settings.py index e5ca414..4784523 100644 --- a/users/views/admin/settings.py +++ b/users/views/admin/settings.py @@ -215,6 +215,11 @@ class PoliciesSettings(AdminSettingsPage): "help_text": "Will only be shown if it has content. Use Markdown for formatting.\nIf you would like to redirect elsewhere, enter just a URL.", "display": "textarea", }, + "policy_issues": { + "title": "Report a Problem Page", + "help_text": "Will only be shown if it has content. Use Markdown for formatting.\nIf you would like to redirect elsewhere, enter just a URL.", + "display": "textarea", + }, } layout = { @@ -222,5 +227,6 @@ class PoliciesSettings(AdminSettingsPage): "policy_rules", "policy_terms", "policy_privacy", + "policy_issues", ], } diff --git a/users/views/settings/profile.py b/users/views/settings/profile.py index 30d3719..662fe12 100644 --- a/users/views/settings/profile.py +++ b/users/views/settings/profile.py @@ -1,4 +1,5 @@ from django import forms +from django.contrib import messages from django.contrib.auth.decorators import login_required from django.core.files import File from django.shortcuts import redirect @@ -124,4 +125,6 @@ class ProfilePage(FormView): Config.set_identity( self.identity, "search_enabled", form.cleaned_data["search_enabled"] ) + + messages.success(self.request, "Your profile has been updated.") return redirect(".") diff --git a/users/views/settings/settings_page.py b/users/views/settings/settings_page.py index d4fc7f2..ab5d4b2 100644 --- a/users/views/settings/settings_page.py +++ b/users/views/settings/settings_page.py @@ -2,6 +2,7 @@ from functools import partial from typing import ClassVar from django import forms +from django.contrib import messages from django.contrib.auth.decorators import login_required from django.core.files import File from django.shortcuts import redirect @@ -113,6 +114,7 @@ class SettingsPage(FormView): field.name, form.cleaned_data[field.name], ) + messages.success(self.request, "Your settings have been saved.") return redirect(".")