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
|
model = Post
|
||||||
# we specify fields up here too because otherwise they won't be
|
# we specify fields up here too because otherwise they won't be
|
||||||
# recognized by the form to update values
|
# recognized by the form to update values
|
||||||
fields: list[str] = ["sticky"]
|
fields = ["sticky", "bump"]
|
||||||
|
|
||||||
def __init__(self, *args, user, **kwargs):
|
def __init__(self, *args, user, **kwargs):
|
||||||
super(PostModifyForm, self).__init__(*args, **kwargs)
|
super(PostModifyForm, self).__init__(*args, **kwargs)
|
||||||
@@ -135,6 +135,8 @@ class PostModifyForm(ModelForm):
|
|||||||
fields = []
|
fields = []
|
||||||
if self.user.has_perm("board.set_sticky"):
|
if self.user.has_perm("board.set_sticky"):
|
||||||
fields += ["sticky"]
|
fields += ["sticky"]
|
||||||
|
if self.user.has_perm("board.set_bump"):
|
||||||
|
fields += ["bump"]
|
||||||
# NOTE:
|
# NOTE:
|
||||||
# We do *not* need to check permissions against these fields we're
|
# 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
|
# 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)
|
image_height = models.IntegerField(null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
permissions = [("set_sticky", "Can sticky post")]
|
permissions = [
|
||||||
|
("set_sticky", "Can sticky post"),
|
||||||
|
("set_bump", "Can bumplock post"),
|
||||||
|
]
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.image:
|
if self.image:
|
||||||
|
|||||||
@@ -5,12 +5,7 @@
|
|||||||
<form method="post" action="{% url 'board:post_modify' post.id %}">
|
<form method="post" action="{% url 'board:post_modify' post.id %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
{% if perms.board.set_sticky %}
|
{{form}}
|
||||||
<tr>
|
|
||||||
<th>{{form.sticky.label_tag}}</th>
|
|
||||||
<td>{{form.sticky}}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr><td> </td><td><input type="submit" value="Modify post" /></td></tr>
|
<tr><td> </td><td><input type="submit" value="Modify post" /></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user