mirror of
https://github.com/QingdaoU/Spirit.git
synced 2025-01-16 09:15:59 +00:00
comment bookmark refactor
This commit is contained in:
parent
b41697833b
commit
f47e97fb11
4
TODO
4
TODO
@ -24,6 +24,7 @@
|
||||
* Moderation section: flags, topics
|
||||
* User groups (permissions)
|
||||
* >> add @username on reply
|
||||
* >> allow mods to create topics on closed categories
|
||||
|
||||
|
||||
Template
|
||||
@ -31,6 +32,9 @@ Template
|
||||
* admin: flag detail delete comment, detail add topic title
|
||||
* admin: add nav to detail templates
|
||||
* Notifications: show all/unread link
|
||||
* Emojis popup selector
|
||||
* bold/italic text doesnt work in google chrome
|
||||
* fenced code blocks
|
||||
|
||||
|
||||
Readme
|
||||
|
@ -9,4 +9,16 @@ class BookmarkForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = CommentBookmark
|
||||
fields = ['comment_number', ]
|
||||
fields = ['comment_number', ]
|
||||
|
||||
def __init__(self, user=None, topic=None, *args, **kwargs):
|
||||
super(BookmarkForm, self).__init__(*args, **kwargs)
|
||||
self.user = user
|
||||
self.topic = topic
|
||||
|
||||
def save(self, commit=True):
|
||||
comment_number = self.cleaned_data['comment_number']
|
||||
|
||||
# Bookmark is created/updated on topic view.
|
||||
CommentBookmark.objects.filter(user=self.user, topic=self.topic)\
|
||||
.update(comment_number=comment_number)
|
@ -19,18 +19,13 @@ def bookmark_create(request, topic_id):
|
||||
return Http404()
|
||||
|
||||
topic = get_object_or_404(Topic, pk=topic_id)
|
||||
form = BookmarkForm(data=request.POST)
|
||||
form = BookmarkForm(user=request.user, topic=topic, data=request.POST)
|
||||
|
||||
if not form.is_valid():
|
||||
return Http404()
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return json_response()
|
||||
|
||||
comment_number = form.cleaned_data['comment_number']
|
||||
|
||||
# Bookmark is created/updated on topic view.
|
||||
CommentBookmark.objects.filter(user=request.user, topic=topic)\
|
||||
.update(comment_number=comment_number)
|
||||
|
||||
return json_response()
|
||||
return Http404()
|
||||
|
||||
|
||||
@login_required
|
||||
|
Loading…
x
Reference in New Issue
Block a user