Add bumplock to post modify form, and add set_bump permission
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -5,12 +5,7 @@
|
||||
<form method="post" action="{% url 'board:post_modify' post.id %}">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{% if perms.board.set_sticky %}
|
||||
<tr>
|
||||
<th>{{form.sticky.label_tag}}</th>
|
||||
<td>{{form.sticky}}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{{form}}
|
||||
<tr><td> </td><td><input type="submit" value="Modify post" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user