-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Union Membership #485
Changes from 100 commits
4bd3fda
31d0ee8
e77e853
83186ba
296aa8b
6b2fdec
37f3fed
ba38547
b54da6f
84eb48e
1d02d5a
c0d9a7d
311df1a
5aed728
3877618
e463a10
1b2012a
a23ef73
827e45c
f064ff4
8b28e7b
4774a2f
6d0f7bd
166c585
b308c10
2536d45
147501c
d88b239
d2ed1ad
43b6164
8932172
81e48b2
f820a5f
7fe1e5f
0f46014
2697ddc
1957477
bef9581
4b837fc
c1e5868
bc79ff8
da395f7
44fecd4
6c478ff
e49a00f
8a5e93c
bbd2d26
4fa7650
d53ae36
9193af0
488017d
686be53
f9cd3c6
7b6a4b7
d5e11ee
812cc33
f00a5a3
03a0bb9
a0ea03e
68771dc
5705259
74621a9
5560f71
b0435ac
a99b3f1
3419c88
f5471ec
f1a768e
aa72570
62bddad
16609bd
6e0895d
812af0d
4e39a09
eb12da7
caf44a8
d0cd9e3
4c2bd15
e632419
429052c
cdd19d3
0383c97
b89a5d6
2dbac2f
4fb4d9b
1f83afa
cee92b1
ea246da
3b8ecbe
293dc21
34c5c32
46951a3
491ea8b
80ad898
a6f18c0
663564b
ae2a799
fff01c9
55adafe
ab5f136
d287504
44b564d
eb33291
a380571
abdea3a
e07880c
75b1313
1c804d0
ee1125b
f67b10a
2f6f7ec
1b5d5ee
0cc2bbe
347785e
d39110f
8fd77dc
b0d1cf7
9052893
d5b7f49
54875f8
91ffecd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
*.pyc | ||
__pycache__ | ||
.env | ||
/db.sqlite3* | ||
staticfiles | ||
*~ | ||
.idea/ | ||
experiments.py | ||
*_old | ||
/backup-* | ||
.DS_Store | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En lille oprydning af filer fra det gamle setup |
||
.vs/ | ||
notes.txt | ||
gamle_db/ | ||
test-results | ||
.coverage | ||
members/static/members/css | ||
.sass-cache/ | ||
public_data.zip | ||
test-screens | ||
generated_emails |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,9 +62,9 @@ | |
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
|
||
SECRET_KEY = env.str("SECRET_KEY") | ||
|
||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = env.bool("DEBUG") | ||
if DEBUG: | ||
|
@@ -186,6 +186,7 @@ | |
# Dont keep job logs more than 7 days old | ||
DJANGO_CRON_DELETE_LOGS_OLDER_THAN = 7 | ||
|
||
QUICKPAY_URL = "https://api.quickpay.net/payments" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skal denne hardcodes? Kan vi ikke gemme værdien i environment-filen? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Det er samme url til test, produktion, staging osv. så den kommer ikke til at ændres. |
||
QUICKPAY_API_KEY = os.environ["QUICKPAY_API_KEY"] | ||
QUICKPAY_PRIVATE_KEY = os.environ["QUICKPAY_PRIVATE_KEY"] | ||
PAYMENT_ID_PREFIX = env.str("PAYMENT_ID_PREFIX") | ||
|
@@ -200,5 +201,6 @@ | |
SECURE_SSL_REDIRECT = env.bool("FORCE_HTTPS") | ||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") | ||
|
||
|
||
LOGIN_URL = "/account/login/" | ||
LOGIN_REDIRECT_URL = "/" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.contrib import admin | ||
|
||
|
||
class MembershipAdmin(admin.ModelAdmin): | ||
list_display = ("person", "union", "sign_up_date") | ||
list_filter = ("union", "sign_up_date", "sign_up_date") | ||
readonly_fields = ["person", "union", "sign_up_date"] | ||
fieldsets = [ | ||
("Medlemskab", {"fields": ("person", "union", "sign_up_date")}), | ||
] | ||
|
||
def has_delete_permission(self, request, obj=None): | ||
return False | ||
|
||
def has_add_permission(self, request, obj=None): | ||
return False | ||
Comment on lines
+10
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Admin view der sørger for at man kan se medlemsskaber men ikke oprette eller slette dem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kan vi overveje at give admin-rolle mulighed for at oprette medlemsskaber? Så vil de fremstå som ubetalte for brugere/frivillige, og vi kan senere bruge automatiske email-remindere, om at logge på og betale. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Det kræver lidt ekstra arbejde, men det kan vi fint. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.contrib import admin | ||
|
||
|
||
class PayableItemAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"added", | ||
"person", | ||
"refunded", | ||
"quick_pay_id", | ||
"accepted", | ||
"amount_ore", | ||
) | ||
list_filter = ("refunded", "accepted") | ||
readonly_fields = [ | ||
"added", | ||
"person", | ||
"refunded", | ||
"quick_pay_id", | ||
"accepted", | ||
"amount_ore", | ||
] | ||
fieldsets = [ | ||
("Data", {"fields": ("person", "added", "amount_ore", "quick_pay_id")}), | ||
("Status", {"fields": ("refunded", "accepted",)}), | ||
] | ||
|
||
def has_delete_permission(self, request, obj=None): | ||
return False | ||
|
||
def has_add_permission(self, request, obj=None): | ||
return False | ||
Comment on lines
+4
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Felterne man kan se skal nok ændres på et tidspunkt. Lige nu er de sat til at ingen kan ændre. Der skal laves en refund knap på dem. Men vi skal nok se på om vi ikke bare vil lave det uden for djangos admin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import forms | ||
from members.models import Person, Union | ||
from members.models import Membership | ||
|
||
|
||
class MembershipForm(forms.Form): | ||
def __init__(self, family_members, *args, **kwargs): | ||
super(MembershipForm, self).__init__(*args, **kwargs) | ||
self.family_members = family_members | ||
self.fields["person"].queryset = Person.objects.filter(pk__in=family_members) | ||
self.fields["person"].initial = 1 | ||
|
||
# TODO exclude closed unions and union where is member | ||
JakobLibak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.fields["union"].queryset = Union.objects.all() | ||
|
||
person = forms.ModelChoiceField(Person.objects.none()) | ||
union = forms.ModelChoiceField(Union.objects.none(), label="Forening") | ||
|
||
def clean(self): | ||
Membership.can_be_member_validator( | ||
self.cleaned_data["person"], self.cleaned_data["union"] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
EmailTemplate, | ||
ActivityParticipant, | ||
Payment, | ||
Person, | ||
Family, | ||
) | ||
|
||
|
@@ -59,23 +58,6 @@ def do(self): | |
curEmail.send() | ||
|
||
|
||
class UpdateDawaData(CronJobBase): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Den kører som via et direkte heroku job |
||
RUN_EVERY_MINS = 1 | ||
|
||
schedule = Schedule(run_every_mins=RUN_EVERY_MINS) | ||
code = "members.update_dawa_data" | ||
|
||
def do(self): | ||
persons = ( | ||
Person.objects.filter(municipality__isnull=True) | ||
.exclude(streetname__exact="") | ||
.exclude(address_invalid__exact=True)[:50] | ||
) | ||
|
||
for person in persons: | ||
person.update_dawa_data() | ||
|
||
|
||
# If it's the first day of the year, make sure to capture all payments that year | ||
class CaptureOutstandingPayments(CronJobBase): | ||
RUN_AT_TIMES = ["01:00"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from django.core.management.base import BaseCommand | ||
from django.core.management import call_command | ||
|
||
MODELS_TO_DUMP = ["department", "union", "address", "emailtemplate", "activity"] | ||
MODELS_TO_DUMP = ["address", "union", "department", "emailtemplate", "activity"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ændrer rækkefølgen da det ellers ikke duer |
||
|
||
|
||
class Command(BaseCommand): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from members.tests.factories import PayableItemFactory | ||
from members.models import PayableItem | ||
|
||
|
||
email_dir = "generated_emails" | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Renders emails with test data" | ||
|
||
def handle(self, *args, **options): | ||
if not os.path.exists(email_dir): | ||
os.makedirs(email_dir) | ||
|
||
_write_payment_confirmation() | ||
|
||
|
||
def _write_payment_confirmation(): | ||
payment = PayableItemFactory.build() | ||
html, text = PayableItem._render_payment_confirmation(payment) | ||
with open(f"{email_dir}/payment_confirmed_email.html", "w+") as htmlFile: | ||
htmlFile.write(html) | ||
with open(f"{email_dir}/payment_confirmed_email.txt", "w+") as txtFile: | ||
txtFile.write(text) | ||
Comment on lines
+1
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En command der laver de mails der bliver sendt ud. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from members.models import PayableItem | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Send emails in queue" | ||
|
||
def handle(self, *args, **options): | ||
PayableItem.send_all_payment_confirmations() |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forslår sætningen ændret til:
To see the emails generated by the system (Payment confirmations etc.) run
Kan det disables igen med en tilsvarende kommando?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Så er teksten rettet.
Der er ikke behov for at disable den.
Det er ment til lokal udvikling, den kører aldrig på prod/staging.
Hvis jeg lokalt kører den så kommer mappen med emails.
Den kan jeg så enten bare slette eller køre kommandoen igen for at få de nye