245 wrapped_text_version, _ , _ = spannify(text_version.get_content()) |
245 wrapped_text_version, _ , _ = spannify(text_version.get_content()) |
246 template_dict = {'text' : text, |
246 template_dict = {'text' : text, |
247 'text_version' : text_version, |
247 'text_version' : text_version, |
248 'title' : text_version.title, # TODO use it ... |
248 'title' : text_version.title, # TODO use it ... |
249 'get_params' : get_params, |
249 'get_params' : get_params, |
250 'json_comments':jsonize(comments, request), |
|
251 'json_filter_datas':jsonize(filter_datas, request), |
|
252 'content' : wrapped_text_version, |
250 'content' : wrapped_text_version, |
253 'client_date_fmt' : settings.CLIENT_DATE_FMT, |
251 'client_date_fmt' : settings.CLIENT_DATE_FMT, |
254 'read_only' : read_only, |
252 'read_only' : read_only, |
255 } |
253 } |
|
254 template_dict['json_comments'] = jsonize(comments, request) |
|
255 template_dict['json_filter_datas'] = jsonize(filter_datas, request) |
256 return render_to_response('site/text_view_comments.html', |
256 return render_to_response('site/text_view_comments.html', |
257 template_dict, |
257 template_dict, |
258 context_instance=RequestContext(request)) |
258 context_instance=RequestContext(request)) |
259 def client_exchange(request): |
259 def client_exchange(request): |
260 ret = None |
260 ret = None |
608 keep_comments = forms.BooleanField(label=ugettext_lazy("Keep comments (optional)"), |
608 keep_comments = forms.BooleanField(label=ugettext_lazy("Keep comments (optional)"), |
609 required=False, |
609 required=False, |
610 initial=True, |
610 initial=True, |
611 help_text=ugettext_lazy("Keep comments (if not affected by the edit)") |
611 help_text=ugettext_lazy("Keep comments (if not affected by the edit)") |
612 ) |
612 ) |
|
613 |
|
614 cancel_modified_scopes = forms.BooleanField(label=ugettext_lazy("Detach comments (optional)"), |
|
615 required=False, |
|
616 initial=True, |
|
617 help_text=ugettext_lazy("If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked.") |
|
618 ) |
613 |
619 |
614 class Meta: |
620 class Meta: |
615 model = TextVersion |
621 model = TextVersion |
616 fields = ('title', 'format', 'content', 'new_version', 'tags', 'note') |
622 fields = ('title', 'format', 'content', 'new_version', 'tags', 'note') |
617 |
623 |
620 new_title = request.POST.get('title') |
626 new_title = request.POST.get('title') |
621 new_format = request.POST.get('format', text.last_text_version.format) |
627 new_format = request.POST.get('format', text.last_text_version.format) |
622 new_note = request.POST.get('note',None) |
628 new_note = request.POST.get('note',None) |
623 new_tags = request.POST.get('tags',None) |
629 new_tags = request.POST.get('tags',None) |
624 keep_comments = bool(request.POST.get('keep_comments',None)) |
630 keep_comments = bool(request.POST.get('keep_comments',None)) |
625 cancel_modified_scopes = (request.POST.get('cancel_modified_scopes',u'1') == u'1') |
631 cancel_modified_scopes = bool(request.POST.get('cancel_modified_scopes',None)) |
626 version = text.get_latest_version() |
632 version = text.get_latest_version() |
627 version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes) |
633 version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes) |
628 |
634 |
629 return version |
635 return version |
630 |
636 |
632 new_content = request.POST.get('content') |
638 new_content = request.POST.get('content') |
633 new_title = request.POST.get('title') |
639 new_title = request.POST.get('title') |
634 new_format = request.POST.get('format', text.last_text_version.format) |
640 new_format = request.POST.get('format', text.last_text_version.format) |
635 new_note = request.POST.get('note',None) |
641 new_note = request.POST.get('note',None) |
636 new_tags = request.POST.get('tags',None) |
642 new_tags = request.POST.get('tags',None) |
637 cancel_modified_scopes = (request.POST.get('cancel_modified_scopes',u'1') == u'1') |
643 |
638 |
644 new_text_version = text.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments=True, cancel_modified_scopes=True, new_version=True) |
639 new_text_version = text.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments=True, cancel_modified_scopes=cancel_modified_scopes, new_version=True) |
|
640 |
645 |
641 keep_comments = bool(request.POST.get('keep_comments',None)) |
646 keep_comments = bool(request.POST.get('keep_comments',None)) |
|
647 cancel_modified_scopes = bool(request.POST.get('cancel_modified_scopes',None)) |
642 new_text_version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes) |
648 new_text_version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes) |
643 new_text_version.user = request.user if request.user.is_authenticated() else None |
649 new_text_version.user = request.user if request.user.is_authenticated() else None |
644 new_text_version.note = request.POST.get('note','') |
650 new_text_version.note = request.POST.get('note','') |
645 new_text_version.email = request.POST.get('email','') |
651 new_text_version.email = request.POST.get('email','') |
646 new_text_version.name = request.POST.get('name','') |
652 new_text_version.name = request.POST.get('name','') |
707 'format': text_version.format, |
713 'format': text_version.format, |
708 'tags': text_version.tags, |
714 'tags': text_version.tags, |
709 'new_version': NEW_TEXT_VERSION_ON_EDIT, |
715 'new_version': NEW_TEXT_VERSION_ON_EDIT, |
710 'note' : '', |
716 'note' : '', |
711 'keep_comments' : True, |
717 'keep_comments' : True, |
|
718 'cancel_modified_scopes' : True, |
712 } |
719 } |
713 if request.user.is_authenticated(): |
720 if request.user.is_authenticated(): |
714 form = EditTextForm(default_data) |
721 form = EditTextForm(default_data) |
715 else: |
722 else: |
716 form = EditTextFormAnon(default_data) |
723 form = EditTextFormAnon(default_data) |