Commits

Benoît Allard committed 75b8833

Warn a user if adding a new message will hide some older ones

  • Participants
  • Parent commits 8230c90

Comments (0)

Files changed (2)

msgboard/templates/addmsg.html

 {% extends "layout.html" %}
 {% block body %}
+{% if nummsg >= 3 %}
+<p> Warning, you already have {{ nummsg }} active messages. Only the three 
+most recent one will be present on the home page. Consider archiving 
+some of them.
+{% endif %}
 <form action="{{ url_for('add_msg') }}" method=post>
   <fieldset>
     <legend>Type your message</legend>
   <h2>Preview:</h2>
   <span id=preview></span>
 </article>
-{% endblock %}
+{% endblock %}

msgboard/views.py

 @app.route('/add/', methods=['GET', 'POST'])
 def add_msg():
     if request.method == 'GET':
-        return render_template('addmsg.html', docutils=controller.publish is not None)
+        user = User.query.filter_by(username=session['username']).first()
+        nummsg = user.messages.count()
+        return render_template('addmsg.html', docutils=controller.publish is not None, nummsg=nummsg)
     if request.form.get('cancel'):
         flash('Message discarded')
         return redirect(url_for('index'))