/copy/", admin.EmojiCopyLocal.as_view()),
path(
"admin/announcements/",
admin.AnnouncementsRoot.as_view(),
diff --git a/templates/admin/emoji.html b/templates/admin/emoji.html
index dda415b..670db55 100644
--- a/templates/admin/emoji.html
+++ b/templates/admin/emoji.html
@@ -32,6 +32,9 @@
|
+ {% if emoji.can_copy_local %}
+
+ {% endif %}
{% if not emoji.is_usable %}
Disabled
diff --git a/users/views/admin/__init__.py b/users/views/admin/__init__.py
index 7a8f5ca..02f6c13 100644
--- a/users/views/admin/__init__.py
+++ b/users/views/admin/__init__.py
@@ -17,6 +17,7 @@ from users.views.admin.domains import ( # noqa
Domains,
)
from users.views.admin.emoji import ( # noqa
+ EmojiCopyLocal,
EmojiCreate,
EmojiDelete,
EmojiEnable,
diff --git a/users/views/admin/emoji.py b/users/views/admin/emoji.py
index fc521a9..a108d13 100644
--- a/users/views/admin/emoji.py
+++ b/users/views/admin/emoji.py
@@ -99,3 +99,18 @@ class EmojiEnable(HTMXActionView):
def action(self, emoji: Emoji):
emoji.public = self.enable
emoji.save()
+
+
+@method_decorator(moderator_required, name="dispatch")
+class EmojiCopyLocal(HTMXActionView):
+ """
+ Duplicates a domain emoji to be local, as long as it is usable and the
+ shortcode is available.
+ """
+
+ model = Emoji
+
+ def action(self, emoji: Emoji):
+ # Force reload locals cache to avoid potential for shortcode dupes
+ Emoji.locals = Emoji.load_locals()
+ emoji.copy_to_local()
|