Procházet zdrojové kódy

Got categories related routes returning to the correct tab in mgmt.html

deadtom před 1 dnem
rodič
revize
c6964828fa

+ 5 - 1
ownchatbot/templates/add.html

@@ -146,7 +146,11 @@
             {% endif %}
             <br><button class="button button2" type="submit">Create {{ reward_type }}</button><br>
         </form>
-        <a href="{{ url_for('web_panels.mgmt', activeTab='managerewards') }}">Cancel</a>
+	{% if reward_type == "category"%}
+        	<a href="{{ url_for('web_panels.mgmt', activeTab='categories') }}">Cancel</a>
+        {% else %}
+            <a href="{{ url_for('web_panels.mgmt', activeTab='managerewards') }}">Cancel</a>
+        {% endif %}
         <br><br>
     </div>
 </body>

+ 2 - 3
ownchatbot/templates/edit.html

@@ -125,11 +125,10 @@
                 <br><button class="button button2" type="submit">Save Changes</button><br>
             </form>
 		{% if reward_data["type"] == "category"%}
-			actab = 'categories'
+			<a href="{{ url_for('web_panels.mgmt', activeTab='categories') }}">Cancel</a>
 		{% else %}
-			actab = 'managerewards'
+			<a href="{{ url_for('web_panels.mgmt', activeTab='managerewards') }}">Cancel</a>
 		{% endif %}
-		<a href="{{ url_for('web_panels.mgmt', activeTab=actab) }}">Cancel</a>
             <br><br>
         </body>
     </div>

+ 6 - 2
ownchatbot/web_panels.py

@@ -305,7 +305,10 @@ def edit(reward_name):
             reread_goals()
         if reward_data['type'] == 'vote':
             reread_votes()
-        return redirect(url_for('web_panels.mgmt', activeTab='managerewards'))
+        if reward_data['type'] == 'category':
+            return redirect(url_for('web_panels.mgmt', activeTab='categories'))
+        else:
+            return redirect(url_for('web_panels.mgmt', activeTab='managerewards'))
 
     return render_template('edit.html',
                            all_cats=all_cats,
@@ -462,6 +465,7 @@ def add(reward_type):
             inactive_categories = current_app.config['INACTIVE_CAT']
             inactive_categories.append(name)  # Add it to the INACTIVE_CAT variable
             reread_categories()  # Write it to categories.py
+            return redirect(url_for('web_panels.mgmt', activeTab='categories'))
         return redirect(url_for('web_panels.mgmt', activeTab='managerewards'))
 
     return render_template('add.html',
@@ -543,7 +547,7 @@ def rereadv():
 @requires_login
 def clearfulfilled():
     if clear_fulfilled_rewards():
-            current_app.logger.info('Cleared fulfilled rewards.')
+        current_app.logger.info('Cleared fulfilled rewards.')
     return redirect(url_for('web_panels.mgmtqueue'))