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

A few macro tweaks

and added the secondary_groups field to the templates
sh4nks 11 лет назад
Родитель
Сommit
28bec66e37

+ 1 - 1
flaskbb/forum/views.py

@@ -169,7 +169,7 @@ def edit_post(post_id):
         flash("You do not have the permissions to edit this post", "error")
         return redirect(url_for('forum.view_topic', topic_id=post.topic_id))
 
-    form = ReplyForm(obj=post)
+    form = ReplyForm()
     if form.validate_on_submit():
         form.populate_obj(post)
         post.date_modified = datetime.datetime.utcnow()

+ 1 - 0
flaskbb/templates/admin/add_user.html

@@ -17,6 +17,7 @@
         {{ render_field(form.website) }}
         {{ render_field(form.avatar) }}
         {{ render_select_field(form.primary_group) }}
+        {{ render_select_field(form.secondary_groups) }}
         {{ render_field(form.signature, rows=5, div_class="col-lg-9") }}
         {{ render_field(form.notes, rows=12, div_class="col-lg-9") }}
 

+ 1 - 0
flaskbb/templates/admin/edit_user.html

@@ -17,6 +17,7 @@
         {{ render_field(form.website) }}
         {{ render_field(form.avatar) }}
         {{ render_select_field(form.primary_group) }}
+        {{ render_select_field(form.secondary_groups) }}
         {{ render_field(form.signature, rows=5, div_class="col-lg-9") }}
         {{ render_field(form.notes, rows=12, div_class="col-lg-9") }}
 

+ 12 - 18
flaskbb/templates/macros.html

@@ -5,7 +5,7 @@
 
 {%- macro field_description(field) -%}
     {% if field.description %}
-        <p class="help-block">{{ field.description }}</p>
+        <span class="help-block">{{ field.description|safe }}</span>
     {% endif %}
 {%- endmacro -%}
 
@@ -41,12 +41,15 @@
         {% else %}
             {{ field(class="form-control") }}
         {%- endif -%}
+
+        {{ field_description(field) }}
+        {{ field_errors(field) }}
     </div>
 </div>
 {%- endmacro -%}
 
 {%- macro render_field(field, div_class='', rows='') -%}
-<div class="form-group">
+<div class="form-group{%- if field.errors %} has-error{%- endif %}">
     {% if div_class %}
     <div class="{{ div_class }}">
     {% else %}
@@ -66,6 +69,9 @@
                 {{ field(class="form-control", placeholder=field.label.text) }}
             {% endif %}
         {%- endif -%}
+
+        {{ field_description(field) }}
+        {{ field_errors(field) }}
     </div>
 </div>
 {%- endmacro -%}
@@ -89,14 +95,8 @@
             {{field(class='form-control', placeholder=field.label.text, **kwargs)}}
         {% endif %}
     {%- endif -%}
-
-    {%- if field.errors %}
-        {%- for error in field.errors %}
-            <span class="help-block">{{error}}</span>
-        {%- endfor %}
-    {%- elif field.description -%}
-        <span class="help-block">{{field.description|safe}}</span>
-    {%- endif %}
+    {{ field_description(field) }}
+    {{ field_errors(field) }}
     </div>
 </div>
 {%- endmacro -%}
@@ -126,14 +126,8 @@
         {% endif %}
     {%- endif -%}
 
-    {%- if field.errors %}
-        {%- for error in field.errors %}
-            <span class="help-block">{{error}}</span>
-        {%- endfor %}
-    {%- elif field.description -%}
-            <span class="help-block">{{field.description|safe}}</span>
-    {%- endif %}
-
+    {{ field_description(field) }}
+    {{ field_errors(field) }}
     </div>
 </div>
 {%- endmacro -%}