Changeset - 0ecebd0f7370
[Not reviewed]
dev
0 3 0
Dennis Fink - 9 years ago 2015-10-27 17:27:31
dennis.fink@c3l.lu
Added total to received donations
3 files changed with 12 insertions and 5 deletions:
0 comments (0 inline, 0 general)
ennstatus/donate/views.py
Show inline comments
 
@@ -60,7 +60,7 @@ def received():
 
        current_app.logger.warn('No donations found!')
 
        return render_template('donate/received.html',
 
                               form=form, csv_file=None,
 
                               year=None, month=None)
 
                               year=None, month=None, total=None)
 

	
 
    if request.method == 'POST':
 
        current_app.logger.debug('Validating form')
 
@@ -82,7 +82,7 @@ def received():
 
                current_app.logger.warn('Date %s not found' % filename)
 
                return render_template('donate/received.html',
 
                                       form=form, csv_file=None,
 
                                       year=year, month=month)
 
                                       year=year, month=month, total=None)
 
        else:
 
            filename = files[-1]
 
            current_app.logger.info('Showing last date %s' % filename)
 
@@ -91,7 +91,10 @@ def received():
 
            form.month.data = '{:02d}'.format(int(month))
 
            csv_file = load_csv(filename)
 

	
 
        total = str(sum(int(row[2]) for row in csv_file))
 
        csv_file = load_csv(filename)
 

	
 
        current_app.logger.info('Return result')
 
        return render_template('donate/received.html',
 
                               form=form, csv_file=csv_file,
 
                               year=year, month=month)
 
                               year=year, month=month, total=total)
ennstatus/templates/donate/macros.html
Show inline comments
 
@@ -10,7 +10,7 @@
 
  <span class="{{ color }}">{{ number }}</span>
 
{% endmacro %}
 

	
 
{% macro create_donations_table(csv_file) %}
 
{% macro create_donations_table(csv_file, total) %}
 
  <div class="table-responsive">
 
    <table class="table table-bordered table-striped">
 
      <thead>
 
@@ -30,6 +30,10 @@
 
            <td>{{ colorize_numbers(row[2]) }}</td>
 
          </tr>
 
        {% endfor %}
 
        <tr>
 
          <td colspan="3" class="text-right"><b>Total:</b></td>
 
          <td>{{ colorize_numbers(total) }}</td>
 
        </tr>
 
      </tbody>
 
    </table>
 
  </div>
ennstatus/templates/donate/received.html
Show inline comments
 
@@ -30,7 +30,7 @@
 
  </div>
 
  <div class="col-md-12">
 
    {% if csv_file %}
 
      {{ macros.create_donations_table(csv_file) }}
 
      {{ macros.create_donations_table(csv_file, total) }}
 
    {% else %}
 
      {% if year and month %}
 
        <p>No donations found for {{ '-'.join([year, month]) }}!</p>
0 comments (0 inline, 0 general)