From 638d8cd34915304ac365ddf5b27856a713070f1a Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Thu, 30 Jun 2022 18:42:16 -0700 Subject: [PATCH] Add bumplock to post modify form, and add set_bump permission Signed-off-by: Alek Ratzloff --- board/forms.py | 4 +++- board/models.py | 5 ++++- board/templates/board/post_modify_view.html | 7 +------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/board/forms.py b/board/forms.py index 55fef39..e7f7861 100644 --- a/board/forms.py +++ b/board/forms.py @@ -127,7 +127,7 @@ class PostModifyForm(ModelForm): model = Post # we specify fields up here too because otherwise they won't be # recognized by the form to update values - fields: list[str] = ["sticky"] + fields = ["sticky", "bump"] def __init__(self, *args, user, **kwargs): super(PostModifyForm, self).__init__(*args, **kwargs) @@ -135,6 +135,8 @@ class PostModifyForm(ModelForm): fields = [] if self.user.has_perm("board.set_sticky"): fields += ["sticky"] + if self.user.has_perm("board.set_bump"): + fields += ["bump"] # NOTE: # We do *not* need to check permissions against these fields we're # setting down here in the self.clean() function in the case that a diff --git a/board/models.py b/board/models.py index fa70b24..5fa5968 100644 --- a/board/models.py +++ b/board/models.py @@ -119,7 +119,10 @@ class Post(models.Model): image_height = models.IntegerField(null=True) class Meta: - permissions = [("set_sticky", "Can sticky post")] + permissions = [ + ("set_sticky", "Can sticky post"), + ("set_bump", "Can bumplock post"), + ] def save(self, *args, **kwargs): if self.image: diff --git a/board/templates/board/post_modify_view.html b/board/templates/board/post_modify_view.html index fec8cbc..61bbd36 100644 --- a/board/templates/board/post_modify_view.html +++ b/board/templates/board/post_modify_view.html @@ -5,12 +5,7 @@
{% csrf_token %} - {% if perms.board.set_sticky %} - - - - - {% endif %} + {{form}}
{{form.sticky.label_tag}}{{form.sticky}}