Skip to content

Commit 35faaea

Browse files
authored
Merge pull request #67 from coredump-ch/updates
Updates
2 parents 63ee3d7 + 327e011 commit 35faaea

37 files changed

+200
-142
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
4+
# Create PRs for Dockerfile updates
5+
- package-ecosystem: "docker"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"
9+
10+
# Create PRs for GitHub Actions updates
11+
# src: https://github.com/marketplace/actions/build-and-push-docker-images#keep-up-to-date-with-github-dependabot
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
17+
# Note: Python dependencies are not handled here. For the Python
18+
# dependencies, we want Dependabot only for security updates, which is
19+
# already enabled through GitHub repository settings.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
DATABASE_URL: 'postgres://pg:passw0rd@localhost/interna'
1919
services:
2020
postgres:
21-
image: postgres:13.2-alpine
21+
image: postgres:14-alpine
2222
env:
2323
POSTGRES_USER: pg
2424
POSTGRES_PASSWORD: passw0rd
@@ -36,7 +36,7 @@ jobs:
3636
- name: Setup python
3737
uses: actions/setup-python@v2
3838
with:
39-
python-version: '3.9'
39+
python-version: '3.11'
4040
- name: Install dependencies
4141
run: |
4242
python -m pip install --upgrade pip

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
# See docker-compose.yml as an example on how to run this image.
1515

16-
FROM docker.io/python:3.9-slim-bullseye
16+
FROM docker.io/python:3.11-slim-bullseye
1717

1818
# Add requirements file
1919
ADD requirements.txt /code/requirements.txt

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ Für die Authentisierung wird ein Session Cookie oder Basic Auth akzeptiert.
2121
Voraussetzungen:
2222

2323
- Python 3
24-
- Pip
25-
- PostgreSQL
24+
- Docker
2625

27-
Datenbank:
26+
Container mit PostgreSQL starten:
2827

29-
createdb interna
28+
docker run -d --name interna-pg \
29+
-e POSTGRES_DB=interna \
30+
-e POSTGRES_USER=interna \
31+
-e POSTGRES_PASSWORD=interna-dev-password \
32+
-p 127.0.0.1:5432:5432 docker.io/postgres:14-alpine
3033

3134
[Virtualenv](https://docs.python.org/3/library/venv.html) erstellen:
3235

@@ -45,7 +48,7 @@ Umgebungsvariablen definieren (`.env` Datei wird automatisch geladen):
4548

4649
echo "DJANGO_DEBUG=True" >> .env
4750
echo "SITE_DOMAIN='http://localhost:8000'" >> .env
48-
echo "DATABASE_URL='postgres://localhost/interna'" >> .env
51+
echo "DATABASE_URL='postgres://interna:interna-dev-password@localhost/interna'" >> .env
4952

5053
Datenbank migrieren:
5154

interna/config/settings.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ def require_env(name):
3535
MANAGERS = ADMINS
3636

3737
DATABASES = {
38-
'default': dj_database_url.config(),
38+
'default': dj_database_url.config(
39+
conn_max_age=600,
40+
conn_health_checks=True,
41+
),
3942
}
4043

44+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
45+
4146
# Hosts/domain names that are valid for this site; required if DEBUG is False
4247
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
4348
if DEBUG:
@@ -61,10 +66,6 @@ def require_env(name):
6166
# to load the internationalization machinery.
6267
USE_I18N = True
6368

64-
# If you set this to False, Django will not format dates, numbers and
65-
# calendars according to the current locale.
66-
USE_L10N = True
67-
6869
# If you set this to False, Django will not use timezone-aware datetimes.
6970
USE_TZ = True
7071

@@ -138,8 +139,6 @@ def require_env(name):
138139
'django.contrib.staticfiles',
139140

140141
'messagegroups',
141-
'django_extensions',
142-
'bootstrapform',
143142
'rest_framework',
144143
'sorl.thumbnail',
145144
'crispy_forms',
@@ -211,6 +210,8 @@ def require_env(name):
211210
}
212211
}
213212

213+
FORM_RENDERER = 'django.forms.renderers.DjangoDivFormRenderer'
214+
214215
REST_FRAMEWORK = {
215216
'DEFAULT_AUTHENTICATION_CLASSES': (
216217
'rest_framework.authentication.SessionAuthentication',

interna/config/tests/test_robots.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.http import HttpResponse
21
from django.test import Client
32

43

interna/crowdfund/migrations/0001_initial.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-20 21:42
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/migrations/0002_auto_20170820_2350.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-20 21:50
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/migrations/0003_auto_20170821_0002.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-20 22:02
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations
63
import sorl.thumbnail.fields
74

interna/crowdfund/migrations/0004_project_initiator.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-20 22:36
3-
from __future__ import unicode_literals
4-
52
from django.conf import settings
63
from django.db import migrations, models
74
import django.db.models.deletion

interna/crowdfund/migrations/0005_fundingpromise.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-27 21:19
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63
import django.db.models.deletion
74

interna/crowdfund/migrations/0006_auto_20170828_0052.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-27 22:52
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/migrations/0007_auto_20170828_0108.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-08-27 23:08
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/migrations/0008_auto_20170906_2346.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-09-06 21:46
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63
import sorl.thumbnail.fields
74

interna/crowdfund/migrations/0009_project_funded.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-09-10 20:05
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/migrations/0010_auto_20170910_2308.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-09-10 21:08
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/migrations/0011_project_forum_thread.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-09-10 21:17
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

interna/crowdfund/tests/test_models.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.core import mail
44

55
from freezegun import freeze_time
6-
from model_mommy import mommy
6+
from model_bakery import baker
77
import pytest
88
import pytz
99

@@ -13,7 +13,7 @@
1313
@pytest.mark.django_db
1414
def test_empty_project():
1515
with freeze_time('2017-01-01'):
16-
p = mommy.make(Project, image=None, amount_required=500)
16+
p = baker.make(Project, image=None, amount_required=500)
1717
assert p.amount_funded() == 0
1818
assert p.percent_funded() == 0
1919
assert len(p.active_promises()) == 0
@@ -24,11 +24,11 @@ def test_empty_project():
2424

2525
@pytest.mark.django_db
2626
def test_regular_project():
27-
p1 = mommy.make(Project, image=None, amount_required=500)
28-
p2 = mommy.make(Project, image=None, amount_required=800)
29-
mommy.make(FundingPromise, project=p1, amount=100, expiry_date=None)
30-
mommy.make(FundingPromise, project=p1, amount=200, expiry_date=None)
31-
mommy.make(FundingPromise, project=p2, amount=400, expiry_date=None)
27+
p1 = baker.make(Project, image=None, amount_required=500)
28+
p2 = baker.make(Project, image=None, amount_required=800)
29+
baker.make(FundingPromise, project=p1, amount=100, expiry_date=None)
30+
baker.make(FundingPromise, project=p1, amount=200, expiry_date=None)
31+
baker.make(FundingPromise, project=p2, amount=400, expiry_date=None)
3232
assert p1.amount_funded() == 300
3333
assert p2.amount_funded() == 400
3434
assert p1.percent_funded() == 60
@@ -44,23 +44,23 @@ def test_regular_project():
4444
@pytest.mark.django_db
4545
def test_funded_freeze():
4646
with freeze_time('2017-01-01'):
47-
p1 = mommy.make(Project, image=None, amount_required=120)
47+
p1 = baker.make(Project, image=None, amount_required=120)
4848
assert p1.amount_funded() == 0
4949
assert p1.percent_funded() == 0
5050
assert p1.funded is None
5151
assert len(p1.active_promises()) == len(p1.expired_promises()) == 0
5252

5353
# First promise without expiration
5454
with freeze_time('2017-01-02'):
55-
mommy.make(FundingPromise, project=p1, amount=80, expiry_date=None)
55+
baker.make(FundingPromise, project=p1, amount=80, expiry_date=None)
5656
assert p1.amount_funded() == 80
5757
assert p1.percent_funded() == 66
5858
assert len(p1.active_promises()) == 1
5959
assert len(p1.expired_promises()) == 0
6060

6161
# Second promise with expiration, not enough to trigger funding
6262
with freeze_time('2017-01-03'):
63-
mommy.make(FundingPromise, project=p1, amount=30,
63+
baker.make(FundingPromise, project=p1, amount=30,
6464
expiry_date=datetime(2017, 1, 4, tzinfo=pytz.utc))
6565
assert p1.amount_funded() == 110
6666
assert p1.percent_funded() == 91
@@ -73,7 +73,7 @@ def test_funded_freeze():
7373

7474
# Create a new expiring promise that reaches the funding goal
7575
with freeze_time('2017-01-05'):
76-
mommy.make(FundingPromise, project=p1, amount=50,
76+
baker.make(FundingPromise, project=p1, amount=50,
7777
expiry_date=datetime(2017, 1, 7, tzinfo=pytz.utc))
7878
assert p1.amount_funded() == 130
7979
assert p1.funded == datetime(2017, 1, 5, tzinfo=pytz.utc)
@@ -85,7 +85,7 @@ def test_funded_freeze():
8585

8686
# We can also add further promises
8787
with freeze_time('2017-01-07'):
88-
mommy.make(FundingPromise, project=p1, amount=10,
88+
baker.make(FundingPromise, project=p1, amount=10,
8989
expiry_date=datetime(2017, 1, 8, tzinfo=pytz.utc))
9090
assert p1.amount_funded() == 140
9191

@@ -100,16 +100,16 @@ def test_funded_freeze():
100100

101101
@pytest.mark.django_db
102102
def test_funding_emails():
103-
p = mommy.make(Project, image=None, amount_required=120,
103+
p = baker.make(Project, image=None, amount_required=120,
104104
initiator__email='foo@bar.baz', title='Yolo')
105105
assert len(mail.outbox) == 0
106-
mommy.make(FundingPromise, project=p, amount=80, expiry_date=None)
106+
baker.make(FundingPromise, project=p, amount=80, expiry_date=None)
107107
assert len(mail.outbox) == 1
108108
assert mail.outbox[0].subject == '80 CHF für dein Projekt "Yolo"!'
109-
mommy.make(FundingPromise, project=p, amount=20, expiry_date=None)
109+
baker.make(FundingPromise, project=p, amount=20, expiry_date=None)
110110
assert len(mail.outbox) == 2
111111
assert mail.outbox[1].subject == '20 CHF für dein Projekt "Yolo"!'
112-
mommy.make(FundingPromise, project=p, amount=30, expiry_date=None)
112+
baker.make(FundingPromise, project=p, amount=30, expiry_date=None)
113113
assert len(mail.outbox) == 4
114114
assert mail.outbox[2].subject == '30 CHF für dein Projekt "Yolo"!'
115115
assert mail.outbox[3].subject == 'Dein Projekt "Yolo" wurde finanziert!'

interna/crowdfund/tests/test_views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import re
66
import pytest
7-
from model_mommy import mommy
7+
from model_bakery import baker
88

99
from crowdfund import models
1010

@@ -38,10 +38,10 @@ def test_status_codes(client, method, url, pk, user, status_code):
3838
get_user_model().objects.create_user(pk=2, username='user2', password='1235')
3939

4040
# PK 1: Ongoing project by user 1
41-
mommy.make(models.Project, pk=1, image=None, initiator=u1, funded=None)
41+
baker.make(models.Project, pk=1, image=None, initiator=u1, funded=None)
4242

4343
# PK 2: Funded project by user 1
44-
mommy.make(models.Project, pk=2, image=None, initiator=u1, funded=timezone.now())
44+
baker.make(models.Project, pk=2, image=None, initiator=u1, funded=timezone.now())
4545

4646
# Login
4747
if user == 1:
@@ -57,7 +57,7 @@ def test_status_codes(client, method, url, pk, user, status_code):
5757

5858
@pytest.mark.django_db
5959
def test_pledge_name_and_email(client):
60-
prj = mommy.make(models.Project)
60+
prj = baker.make(models.Project)
6161
path = '/crowdfund/projects/{}/'.format(prj.pk)
6262
response = client.get(path)
6363
assert response.status_code == 200

interna/front/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.utils.decorators import method_decorator
33

44

5-
class LoginRequiredMixin(object):
5+
class LoginRequiredMixin:
66

77
@method_decorator(login_required)
88
def dispatch(self, *args, **kwargs):

interna/front/static/css/style.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ iframe.fullwidth {
33
height: 700px;
44
}
55

6+
form ul.errorlist {
7+
color: #d30000;
8+
}
9+
10+
body.login form div {
11+
margin: 0 0 8px;
12+
}
13+
14+
body.login form label {
15+
width: 130px;
16+
}
17+
618
body.members table {
719
font-size: 0.85em;
820
}

interna/front/templates/front/login.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends 'front/base.html' %}
2-
{% load tabs bootstrap %}
2+
{% load tabs crispy_forms_tags %}
33

44
{% block bodyclass %}login{% endblock %}
55

@@ -16,7 +16,7 @@ <h1>Login</h1>
1616

1717
<form role="form" action="{% url 'front:login' %}" method="post">
1818
{% csrf_token %}
19-
{{ form|bootstrap }}
19+
{{ form }}
2020
<button type="submit" class="btn btn-primary">Login</button>
2121
<input type="hidden" name="next" value="{{ next }}" />
2222
</form>

0 commit comments

Comments
 (0)