Просмотр исходного кода

Made MD editors play nice with floppyforms.

Rafał Pitoń 12 лет назад
Родитель
Сommit
b48b16b6d3

+ 18 - 14
misago/apps/threadtype/posting/forms.py

@@ -32,15 +32,15 @@ class PostingForm(FloodProtectionMixin, Form, ValidatePostLengthMixin):
                     current_weight = self.thread.weight
                 except AttributeError:
                     current_weight = 0
-                self.fields['thread_weight'] = forms.TypedChoiceField(widget=forms.RadioSelect,
-                                                                      choices=thread_weight,
-                                                                      required=False,
-                                                                      coerce=int,
-                                                                      initial=current_weight)
+                self.add_field('thread_weight', forms.TypedChoiceField(widget=forms.RadioSelect,
+                                                                       choices=thread_weight,
+                                                                       required=False,
+                                                                       coerce=int,
+                                                                       initial=current_weight))
 
         # Can we lock threads?
         if self.include_close_thread and self.request.acl.threads.can_close(self.forum):
-            self.fields['close_thread'] = forms.BooleanField(required=False)
+            self.add_field('close_thread', forms.BooleanField(required=False))
 
         # Give inheritor chance to set custom fields
         try:
@@ -62,17 +62,19 @@ class PostingForm(FloodProtectionMixin, Form, ValidatePostLengthMixin):
 class NewThreadForm(PostingForm, ValidateThreadNameMixin):
     def finalize_form(self):
         super(NewThreadForm, self).finalize_form()
-        self.layout[0][1].append(('thread_name', {'label': _("Thread Name")}))
-        self.fields['thread_name'] = forms.CharField(max_length=settings.thread_name_max,
-                                                     validators=[validate_sluggable(_("Thread name must contain at least one alpha-numeric character."),
-                                                                                    _("Thread name is too long. Try shorter name."))])
+        self.add_field('thread_name', forms.CharField(label=_("Thread Name"),
+                                                      max_length=settings.thread_name_max,
+                                                      validators=[validate_sluggable(_("Thread name must contain at least one alpha-numeric character."),
+                                                                                     _("Thread name is too long. Try shorter name."))]))
 
 
 class EditThreadForm(NewThreadForm, ValidateThreadNameMixin):
     def finalize_form(self):
         super(EditThreadForm, self).finalize_form()
-        self.fields['edit_reason'] = forms.CharField(max_length=255, required=False, help_text=_("Optional reason for editing this thread."))
-        self.layout[0][1].append(('edit_reason', {'label': _("Edit Reason")}))
+        self.add_field('edit_reason', forms.CharField(label=_("Edit Reason"),
+                                                      help_text=_("Optional reason for editing this thread."),
+                                                      max_length=255,
+                                                      required=False))
 
 
 class NewReplyForm(PostingForm):
@@ -82,5 +84,7 @@ class NewReplyForm(PostingForm):
 class EditReplyForm(PostingForm):
     def finalize_form(self):
         super(EditReplyForm, self).finalize_form()
-        self.fields['edit_reason'] = forms.CharField(max_length=255, required=False, help_text=_("Optional reason for editing this reply."))
-        self.layout[0][1].append(('edit_reason', {'label': _("Edit Reason")}))
+        self.add_field('edit_reason', forms.CharField(label=_("Edit Reason"),
+                                                      help_text=_("Optional reason for editing this reply."),
+                                                      max_length=255,
+                                                      required=False))

+ 1 - 1
templates/cranefly/private_threads/posting.html

@@ -68,7 +68,7 @@
             <hr>
             <h4>{% trans %}Message Body{% endtrans %}</h4>
             {% endif %}
-            {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
+            {{ editor.editor(form.post, get_button(), rows=8, extra=get_extra()) }}
             {% if 'edit_reason' in form.fields or (action == 'new_reply' and 'invite_users' in form.fields) %}
             <hr>
             {% if action == 'new_reply' and 'invite_users' in form.fields %}

+ 1 - 1
templates/cranefly/reports/posting.html

@@ -64,7 +64,7 @@
             <hr>
             <h4>{% trans %}Message Body{% endtrans %}</h4>
             {% endif %}
-            {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
+            {{ editor.editor(form.post, get_button(), rows=8, extra=get_extra()) }}
             {% if intersect(form.fields, ('edit_reason', 'thread_weight')) %}
             <hr>
             {% if 'edit_reason' in form.fields %}

+ 1 - 1
templates/cranefly/threads/posting.html

@@ -64,7 +64,7 @@
             <hr>
             <h4>{% trans %}Message Body{% endtrans %}</h4>
             {% endif %}
-            {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
+            {{ editor.editor(form.post, get_button(), rows=8, extra=get_extra()) }}
             {% if intersect(form.fields, ('edit_reason', 'thread_weight', 'close_thread')) %}
             <hr>
             {% if 'edit_reason' in form.fields %}

+ 1 - 1
templates/cranefly/threads/thread.html

@@ -41,7 +41,7 @@
 
   <div class="thread-buttons">
     {{ pager() }}
-    {% if user.is_authenticated() %}    
+    {% if user.is_authenticated() %}
     {% if acl.threads.can_reply(forum, thread) %}
     <a href="{{ url('thread_reply', thread=thread.pk, slug=thread.slug) }}" class="btn btn-inverse pull-right"><i class="icon-pencil"></i> {% trans %}Reply{% endtrans %}</a>
     {% endif %}

+ 2 - 2
templates/cranefly/usercp/signature.html

@@ -27,12 +27,12 @@
 
   <form action="{{ url('usercp_signature') }}" method="post">
     <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
-    {{ editor.editor(form.fields.signature, _('Save Signature'),
+    {{ editor.editor(form.signature, _('Save Signature'),
       hide_links=(not acl.usercp.allow_signature_links()),
       hide_images=(not acl.usercp.allow_signature_images()),
       hide_hr=True) }}
   </form>
-  
+
 </div>
 {% endblock %}