242 comments = get_viewable_comments(request, text_version.comment_set.filter(reply_to__isnull=True),text) |
242 comments = get_viewable_comments(request, text_version.comment_set.filter(reply_to__isnull=True),text) |
243 filter_datas = get_filter_datas(request, text_version, text) |
243 filter_datas = get_filter_datas(request, text_version, text) |
244 |
244 |
245 get_params = simplejson.dumps(request.GET) |
245 get_params = simplejson.dumps(request.GET) |
246 wrapped_text_version, _ , _ = spannify(text_version.get_content()) |
246 wrapped_text_version, _ , _ = spannify(text_version.get_content()) |
247 template_dict = {'text' : text, |
247 |
248 'text_version' : text_version, |
248 from cm.models import ApplicationConfiguration |
249 'title' : text_version.title, # TODO use it ... |
249 categories = {} |
250 'get_params' : get_params, |
250 for i in range(1, 6): |
251 'content' : wrapped_text_version, |
251 if text_version.__dict__['category_' + str(i)].lower() != 'none': |
252 'client_date_fmt' : settings.CLIENT_DATE_FMT, |
252 if text_version.__dict__['category_' + str(i)] != None and text_version.__dict__['category_' + str(i)] != '': |
253 'read_only' : read_only, |
253 categories[i] = text_version.__dict__['category_' + str(i)] |
254 } |
254 else: |
|
255 if ApplicationConfiguration.get_key('workspace_category_' + str(i)) != None and ApplicationConfiguration.get_key('workspace_category_' + str(i)) != '': |
|
256 categories[i] = ApplicationConfiguration.get_key('workspace_category_' + str(i)) |
|
257 |
|
258 template_dict = { |
|
259 'text' : text, |
|
260 'text_version' : text_version, |
|
261 'title' : text_version.title, # TODO use it ... |
|
262 'get_params' : get_params, |
|
263 'content' : wrapped_text_version, |
|
264 'client_date_fmt' : settings.CLIENT_DATE_FMT, |
|
265 'read_only' : read_only, |
|
266 } |
255 template_dict['json_comments'] = jsonize(comments, request) |
267 template_dict['json_comments'] = jsonize(comments, request) |
256 template_dict['json_filter_datas'] = jsonize(filter_datas, request) |
268 template_dict['json_filter_datas'] = jsonize(filter_datas, request) |
257 from cm.models import ApplicationConfiguration |
269 if categories: |
|
270 categories[0] = 'none' |
|
271 template_dict['categories'] = jsonize(categories, request) |
258 custom_css_str = ApplicationConfiguration.get_key('custom_css') |
272 custom_css_str = ApplicationConfiguration.get_key('custom_css') |
259 if custom_css_str: |
273 if custom_css_str: |
260 custom_css = cssutils.parseString(custom_css_str) |
274 custom_css = cssutils.parseString(custom_css_str) |
261 for css_rule in custom_css: |
275 for css_rule in custom_css: |
262 if css_rule.type == css_rule.STYLE_RULE and css_rule.wellformed: |
276 if css_rule.type == css_rule.STYLE_RULE and css_rule.wellformed: |
431 |
445 |
432 if version_key : |
446 if version_key : |
433 text_version = get_textversion_by_keys_or_404(version_key, adminkey, key) |
447 text_version = get_textversion_by_keys_or_404(version_key, adminkey, key) |
434 else : |
448 else : |
435 text_version = text.get_latest_version() |
449 text_version = text.get_latest_version() |
|
450 from cm.models import ApplicationConfiguration |
436 template_dict = {'text' : text, 'text_version' : text_version} |
451 template_dict = {'text' : text, 'text_version' : text_version} |
437 return render_to_response('site/text_view_frame.html', |
452 return render_to_response('site/text_view_frame.html', |
438 template_dict, |
453 template_dict, |
439 context_instance=RequestContext(request)) |
454 context_instance=RequestContext(request)) |
440 |
455 |
909 class SettingsTextForm(ModelForm): |
924 class SettingsTextForm(ModelForm): |
910 # example name = forms.CharField(label=_("Name (optional)"), widget=forms.TextInput, required=False) |
925 # example name = forms.CharField(label=_("Name (optional)"), widget=forms.TextInput, required=False) |
911 |
926 |
912 class Meta: |
927 class Meta: |
913 model = TextVersion |
928 model = TextVersion |
914 fields = ('mod_posteriori',) |
929 fields = ('mod_posteriori', 'category_1', 'category_2', 'category_3', 'category_4', 'category_5') |
915 |
930 |
916 @has_perm_on_text('can_manage_text') |
931 @has_perm_on_text('can_manage_text') |
917 def text_settings(request, key): |
932 def text_settings(request, key): |
918 text = get_text_by_keys_or_404(key) |
933 text = get_text_by_keys_or_404(key) |
919 |
934 |
922 form = SettingsTextForm(request.POST, instance = text_version) |
937 form = SettingsTextForm(request.POST, instance = text_version) |
923 |
938 |
924 if form.is_valid(): |
939 if form.is_valid(): |
925 form.save() |
940 form.save() |
926 display_message(request, _(u'Text settings updated')) |
941 display_message(request, _(u'Text settings updated')) |
927 return redirect(request, 'text-view', args=[text.key]) |
942 return redirect(request, 'text-settings', args=[text.key]) |
928 else: |
943 else: |
929 form = SettingsTextForm(instance = text_version) |
944 form = SettingsTextForm(instance = text_version) |
930 |
945 |
931 template_dict = {'text' : text, 'form' : form} |
946 template_dict = {'text' : text, 'form' : form} |
932 |
947 |