Skip to content

Commit

Permalink
Merge branch 'master' into mhvis/202312/balance
Browse files Browse the repository at this point in the history
  • Loading branch information
mhvis committed Jan 1, 2024
2 parents 96115a4 + a0732dc commit a7b3075
Show file tree
Hide file tree
Showing 50 changed files with 500 additions and 301 deletions.
17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM python:3.11
FROM python:3.12

# Python settings
ENV PYTHONUNBUFFERED=1

WORKDIR /app/src

# The production dependencies are gunicorn and psycopg2.
# The version number is pinned but it should be safe to upgrade.
RUN pip install --no-cache-dir gunicorn==20.1.0 psycopg2==2.9.5
# First copy only the requirements to cache them early.
#
# Gunicorn and psycopg are necessary in production only.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt gunicorn==21.2.0 psycopg[binary]==3.1.16

# Copy the rest
COPY . .

# Collect static files
Expand All @@ -24,9 +24,4 @@ ARG BUILD_TIMESTAMP
ENV COMMIT_SHA=$COMMIT_SHA
ENV BUILD_TIMESTAMP=$BUILD_TIMESTAMP

# Create user
RUN useradd -u 1001 appuser && chown appuser /app/media
USER appuser

# By default launch gunicorn on :8000
CMD ["gunicorn", "-w", "3", "-b", "0.0.0.0:8000", "scaladining.wsgi"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ The app can also be built and run with Docker.
## Development commands

* Lint code: `flake8`
* Blacken the code `black .`
* Sort the imports with `isort --ac .`
* Blacken the code: `black .`
* Sort the imports: `isort --ac .`
* Run unit tests: `python manage.py test`
* Create superuser: `python manage.py createsuperuser`
* Coverage: `coverage run manage.py test`
Expand Down
6 changes: 3 additions & 3 deletions assets/templates/accounts/association_credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
Association balance: <strong>{{ association.account.get_balance|euro }}</strong>
</p>
<p>
<a class="btn btn-primary" href="{% url 'association_transaction_add' association_name=association.slug %}">
<a class="btn btn-primary" href="{% url 'association_transaction_add' slug=association.slug %}">
<i class="fas fa-plus"></i> Money transfer
</a>
{% if association.has_min_exception %}
<a href="{% url 'association_process_negatives' association_name=association.slug %}"
<a href="{% url 'association_process_negatives' slug=association.slug %}"
class="btn btn-secondary">
Autocorrect negative credits
</a>
{% endif %}
<a href="{% url 'association_transactions_csv' association_name=association.slug %}"
<a href="{% url 'credits:transaction_csv' pk=association.account.pk %}"
class="btn btn-secondary">
<i class="fa fa-file-export"></i> Download CSV
</a>
Expand Down
2 changes: 1 addition & 1 deletion assets/templates/accounts/association_members.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% block details %}
<p>
<a class="btn btn-primary" href="{% url 'association_members_edit' association_name=association.slug %}">
<a class="btn btn-primary" href="{% url 'association_members_edit' slug=association.slug %}">
<i class="fas fa-edit"></i> Edit list
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion assets/templates/accounts/association_members_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block details %}
<p>
<a class="btn btn-primary" href="{% url 'association_members' association_name=association.slug %}">
<a class="btn btn-primary" href="{% url 'association_members' slug=association.slug %}">
Back
</a>
</p>
Expand Down
4 changes: 2 additions & 2 deletions assets/templates/accounts/association_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h3>New member requests</h3>
{% if pending_memberships %}
<form method="post"
action="{% url 'association_members_edit' association_name=association.slug %}?next={{ request.path }}">
action="{% url 'association_members_edit' slug=association.slug %}?next={{ request.path }}">
<div class="table-responsive">
{% csrf_token %}
<table class="table table-hover">
Expand All @@ -34,7 +34,7 @@ <h3>Association balance</h3>
</div>
</div>
<p class="mt-3">
<a href="{% url 'association_transaction_add' association_name=association.slug %}" class="btn btn-primary">
<a href="{% url 'association_transaction_add' slug=association.slug %}" class="btn btn-primary">
<i class="fas fa-plus"></i> Money transfer
</a>
</p>
Expand Down
12 changes: 6 additions & 6 deletions assets/templates/accounts/associations_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ <h2>{{ association }}</h2>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link{% block tab_overview %}{% endblock %}"
href="{% url 'association_overview' association_name=association.slug %}">Overview
href="{% url 'association_overview' slug=association.slug %}">Overview
{% if notify_overview %}<span class="badge badge-pill badge-warning">!</span>{% endif %}
</a>
</li>
<li class="nav-item">
<a class="nav-link{% block tab_credits %}{% endblock %}"
href="{% url 'association_credits' association_name=association.slug %}">Credits</a>
href="{% url 'association_credits' slug=association.slug %}">Credits</a>
</li>
<li class="nav-item">
<a class="nav-link{% block tab_members %}{% endblock %}"
href="{% url 'association_members' association_name=association.slug %}">Members</a>
href="{% url 'association_members' slug=association.slug %}">Members</a>
</li>
<li class="nav-item">
<a class="nav-link{% block tab_settings %}{% endblock %}"
href="{% url 'association_settings' association_name=association.slug %}">Settings</a>
href="{% url 'association_settings' slug=association.slug %}">Settings</a>
</li>

{% if association.has_site_stats_access %}
<li class="nav-item">
<a class="nav-link{% block tab_site_dining %}{% endblock %}"
href="{% url 'association_site_dining_stats' association_name=association.slug %}">Site Dining</a>
href="{% url 'association_site_dining_stats' slug=association.slug %}">Site Dining</a>
</li>
<li class="nav-item">
<a class="nav-link{% block tab_site_credits %}{% endblock %}"
href="{% url 'association_site_credit_stats' association_name=association.slug %}">Site Credits</a>
href="{% url 'association_site_credit_stats' slug=association.slug %}">Site Credits</a>
</li>
{% endif %}
</ul>
Expand Down
24 changes: 16 additions & 8 deletions assets/templates/accounts/site_credit.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block details %}
<p>
<a href="{% url 'association_site_transaction_add' association_name=association.slug %}"
<a href="{% url 'association_site_transaction_add' slug=association.slug %}"
class="btn btn-primary">
<i class="fas fa-plus"></i> New site-wide transaction
</a>
Expand All @@ -15,14 +15,20 @@ <h3>Associations</h3>
<thead>
<tr>
<th scope="col">Association</th>
<th scope="col">Balance</th>
<th scope="col" class="text-right w-25">Balance</th>
<th scope="col" class="text-right w-25">#</th>
</tr>
</thead>
<tbody>
{% for a in associations %}
<tr>
<td>{{ a.name }}</td>
<td>{{ a.account.get_balance }}</td>
<td class="text-right">{{ a.account.get_balance }}</td>
<td class="text-right">
<a href="{% url 'association_site_credit_detail' slug=association.slug pk=a.account.pk %}">
Details
</a>
</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -39,7 +45,8 @@ <h3>Bookkeeping accounts</h3>
<thead>
<tr>
<th scope="col">Account</th>
<th scope="col">Balance</th>
<th scope="col" class="text-right w-25">Balance</th>
<th scope="col" class="text-right w-25">#</th>
</tr>
</thead>
<tbody>
Expand All @@ -49,12 +56,13 @@ <h3>Bookkeeping accounts</h3>
{{ a.get_special_display }}
<br>
<small class="text-muted">{{ a.get_special_description }}</small>
<br>
<a href="{% url 'association_site_credit_detail' association_name=association.slug slug=a.special %}">
Account details
</td>
<td class="text-right">{{ a.get_balance }}</td>
<td class="text-right">
<a href="{% url 'association_site_credit_detail' slug=association.slug pk=a.pk %}">
Details
</a>
</td>
<td>{{ a.get_balance }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
55 changes: 49 additions & 6 deletions assets/templates/accounts/site_credit_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,57 @@

{% block details %}
<p>
Account: <strong>{{ object }}</strong>
({% if object.association %}association{% elif object.user %}user{% else %}bookkeeping account{% endif %}).
Balance: <strong>{{ object.get_balance|euro }}</strong>.
<a href="{% url "association_site_credit_stats" slug=association.slug %}"
class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back
</a>
</p>

<div class="row mb-3">
<div class="col-md-2"><strong>Account</strong></div>
<div class="col-md-10">
{{ object }}
<br>
<small class="text-muted">
{% if object.association %}Association{% elif object.user %}User{% else %}Bookkeeping account{% endif %}
</small>
</div>
</div>

<div class="row mb-3">
<div class="col-md-2"><strong>Balance</strong></div>
<div class="col-md-10">{{ object.get_balance|euro }}</div>
</div>

<div class="mb-3">
<a href="{% url "credits:transaction_csv" pk=object.pk %}"
class="btn btn-secondary">
<i class="fa fa-file-export"></i>
Download CSV
</a>
</div>

{# We only handle and show the form if we're on page 1 #}
{% if page_obj.number == 1 %}
<h3>Retrieve income/outcome flow</h3>
<form method="get">
{% include "snippets/bootstrap_form_one_line.html" with horizontal=True form=date_range_form submit_value='Retrieve' %}
<hr>
<h3>Income/outcome flow</h3>
<form method="get"
class="form-inline mb-2"
action="{% url "association_site_credit_detail" slug=association.slug pk=object.pk %}">
<label for="rangeFromInput" class="my-1 mr-2">From</label>
<input type="date"
id="rangeFromInput"
name="from"
value="{{ range_from }}"
class="form-control my-1 mr-sm-2">
<label for="rangeToInput" class="my-1 mr-2">To</label>
<input type="date"
id="rangeToInput"
name="to"
value="{{ range_to }}"
class="form-control my-1 mr-sm-2">
<button type="submit"
class="btn btn-primary">Retrieve</button>
</form>

<div class="table-responsive">
Expand All @@ -35,6 +77,7 @@ <h3>Retrieve income/outcome flow</h3>
</table>
</div>
{% endif %}
<hr>
<h3>All transactions</h3>
{% include 'credit_management/transaction_table.html' with object_list=page_obj.object_list account_self=object %}

Expand Down
3 changes: 3 additions & 0 deletions assets/templates/accounts/site_dining_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@
</table>
</div>

<small class="text-muted">
Similar statistics can also be found <a href="{% url "statistics" %}">here</a>.
</small>
{% endblock %}
5 changes: 3 additions & 2 deletions assets/templates/accounts/snippet_member_edits.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load l10n %}
{% load humanize %}
<tr>
<td>{{ entry.related_user.get_username }}</td>
Expand All @@ -15,7 +16,7 @@
{# Verify button #}
<td>
{% if not entry.is_verified %}
<button type="submit" name="validate-yes-{{ entry.id }}" class="btn btn-block btn-outline-success">
<button type="submit" name="validate-yes-{{ entry.id|unlocalize }}" class="btn btn-block btn-outline-success">
{# Only icon because the button is not wide enough for text. #}
<i class="fa fa-check-circle"></i>
</button>
Expand All @@ -24,7 +25,7 @@
{# Deny button #}
<td>
{% if entry.is_verified or not entry.verified_on %}
<button type="submit" name="validate-no-{{ entry.id }}" class="btn btn-block btn-outline-danger">
<button type="submit" name="validate-no-{{ entry.id|unlocalize }}" class="btn btn-block btn-outline-danger">
<i class="fa fa-times-circle"></i>
</button>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions assets/templates/accounts/user_history_claimed.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
{% for entry in object_list %}
<tr>
<td>
{{ entry.date }}
{{ entry.date|date:"SHORT_DATE_FORMAT" }}
</td>
<td>
{{ entry.dish }}
</td>
<td>
{{ entry.association.slug }}
{{ entry.association.get_short_name }}
</td>
<td>
{{ entry.diners.count }}
Expand Down
4 changes: 2 additions & 2 deletions assets/templates/accounts/user_history_joined.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
{% for entry in object_list %}
<tr>
<td>
{{ entry.dining_list.date }}
{{ entry.dining_list.date|date:"SHORT_DATE_FORMAT" }}
</td>
<td>
{{ entry.dining_list.dish }}
</td>
<td>
{{ entry.dining_list.association.slug }}
{{ entry.dining_list.association.get_short_name }}
</td>
<td>
{% if entry.has_shopped %} Shop {% endif %}
Expand Down
4 changes: 2 additions & 2 deletions assets/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
{% endif %}
{% for association in user.boards %}
<a class="dropdown-item {{ justify }}"
href="{% url 'association_overview' association_name=association.slug %}">
href="{% url 'association_overview' slug=association.slug %}">
<span>
{{ association.slug }}
{{ association.get_short_name }}
{% if association.requires_action %}
<span class="badge badge-pill badge-warning">!</span>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2>Transaction history</h2>
<a href="{% url 'credits:transaction_add' %}" class="btn btn-primary">
<i class="fas fa-plus"></i> Money transfer
</a>
<a href="{% url 'credits:transaction_csv' %}" class="btn btn-secondary">
<a href="{% url 'credits:transaction_csv' pk=user.account.pk %}" class="btn btn-secondary">
<i class="fas fa-file-export"></i> Download CSV
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion assets/templates/credit_management/transaction_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<tbody>
{% for tx in object_list %}
<tr>
<td>{{ tx.moment }}</td>
<td>{{ tx.moment|date:"SHORT_DATE_FORMAT" }}</td>
<td>
{% if tx.source == account_self %}
{{ tx.target }}
Expand Down
2 changes: 1 addition & 1 deletion assets/templates/dining_lists/dining_day.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="col-lg-4 mt-3 mt-lg-0 d-flex flex-column justify-content-center align-items-center">
{# During weekend, next Monday is bold. If we don't want that, use 'today' instead of 'upcoming' here #}
<h4 class="my-0 {% if date.upcoming == date %}font-weight-bold{% endif %}">
{{ date|date|capfirst }}
{{ date|date:"l j F"|capfirst }}
</h4>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion assets/templates/dining_lists/dining_slot.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="fixed-bottom bg-light">
<div class="container text-center">
<p class="lead">
{{ dining_list.association }} - {{ dining_list.date }}
{{ dining_list.association }} - {{ dining_list.date|date:"l j F" }}
</p>
<div class="row">
<div class="col px-1">
Expand Down
Loading

0 comments on commit a7b3075

Please sign in to comment.