comment bookmark refactor

This commit is contained in:
nitely 2014-05-12 19:29:51 -03:00
parent b41697833b
commit f47e97fb11
3 changed files with 22 additions and 11 deletions

4
TODO
View File

@ -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

View File

@ -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)

View File

@ -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