Skip to content
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

Closed
wants to merge 121 commits into from
Closed
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
4bd3fda
Updated lock file
Rotendahl Jan 27, 2020
31d0ee8
Merge branch 'master' of github.com:Rotendahl/forenings_medlemmer
Rotendahl Feb 8, 2020
e77e853
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Feb 8, 2020
83186ba
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 2, 2020
296aa8b
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 4, 2020
6b2fdec
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 5, 2020
37f3fed
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 8, 2020
ba38547
Cleaned markup, changed redirect page to overview and activities
Rotendahl Mar 9, 2020
b54da6f
Updated datepicker to use browser default
Rotendahl Mar 10, 2020
84eb48e
Wrote get_open_departments function
Rotendahl Mar 10, 2020
1d02d5a
Cleaned data
Rotendahl Mar 10, 2020
c0d9a7d
Updated pages, tabs for waitlist and mobile tables
Rotendahl Mar 10, 2020
311df1a
Updated test
Rotendahl Mar 10, 2020
5aed728
updated test
Rotendahl Mar 10, 2020
3877618
:art: Fix formatting of 6 files for commit 5aed728
Mar 10, 2020
e463a10
Merge pull request #8 from CodingPirates/unibeautify/pull-request-476
Rotendahl Mar 10, 2020
1b2012a
Updates add person form
Rotendahl Mar 10, 2020
a23ef73
Filter departments by region
Rotendahl Mar 10, 2020
827e45c
Updated region filer
Rotendahl Mar 10, 2020
f064ff4
Testing guide
Rotendahl Mar 10, 2020
8b28e7b
Update CONTRIBUTING.md
Rotendahl Mar 13, 2020
4774a2f
New styling
Rotendahl Mar 14, 2020
6d0f7bd
Text changes
Rotendahl Mar 16, 2020
166c585
:art: Fix formatting of 1 file for commit 6d0f7bd
Mar 16, 2020
b308c10
Merge pull request #9 from CodingPirates/unibeautify/pull-request-476
Rotendahl Mar 16, 2020
2536d45
More text changes
Rotendahl Mar 16, 2020
147501c
Updated text
Rotendahl Mar 16, 2020
d88b239
Updated text again
Rotendahl Mar 16, 2020
d2ed1ad
Merge branch 'contrib-update' of https://github.com/CodingPirates/for…
Rotendahl Mar 16, 2020
43b6164
Updated tests
Rotendahl Mar 16, 2020
8932172
Align tiles
Rotendahl Mar 16, 2020
81e48b2
Start of membership model
Rotendahl Mar 17, 2020
f820a5f
Migrations
Rotendahl Mar 17, 2020
7fe1e5f
Ran black
Rotendahl Mar 17, 2020
0f46014
Form working without payment
Rotendahl Mar 18, 2020
2697ddc
Fixed url in js
Rotendahl Mar 18, 2020
1957477
Merge
Rotendahl Mar 19, 2020
bef9581
:art: Fix formatting of 4 files for commit 1957477
Mar 19, 2020
4b837fc
Merge pull request #11 from CodingPirates/unibeautify/pull-request-485
Rotendahl Mar 19, 2020
c1e5868
Fixed migrations
Rotendahl Mar 19, 2020
bc79ff8
Merge branch 'membership' of github.com:Rotendahl/forenings_medlemmer…
Rotendahl Mar 19, 2020
da395f7
Ran black
Rotendahl Mar 19, 2020
44fecd4
Updated test
Rotendahl Mar 19, 2020
6c478ff
Updated Factories
Rotendahl Mar 21, 2020
e49a00f
Payment model and env cleanup
Rotendahl Mar 22, 2020
8a5e93c
changed comment
Rotendahl Mar 22, 2020
bbd2d26
Updated heroku env
Rotendahl Mar 22, 2020
4fa7650
Updated CSS
Rotendahl Mar 22, 2020
d53ae36
First step of new mails
Rotendahl Mar 23, 2020
9193af0
fixed tests
Rotendahl Mar 24, 2020
488017d
:art: Fix formatting of 1 file for commit 9193af0
Mar 24, 2020
686be53
Merge pull request #12 from CodingPirates/unibeautify/pull-request-485
Rotendahl Mar 24, 2020
f9cd3c6
Ran black and flake
Rotendahl Mar 24, 2020
7b6a4b7
Merge branch 'membership' of github.com:Rotendahl/forenings_medlemmer…
Rotendahl Mar 24, 2020
d5e11ee
Updated dependecies, switch to django 3
Rotendahl Mar 25, 2020
812cc33
Merge branch 'master' into quickpay_update
Rotendahl Mar 25, 2020
f00a5a3
Removed django-responsive and added test for loading admin
Rotendahl Mar 25, 2020
03a0bb9
Merge branch 'quickpay_update' of github.com:Rotendahl/forenings_medl…
Rotendahl Mar 25, 2020
a0ea03e
removed unused imports
Rotendahl Mar 25, 2020
68771dc
Updated test
Rotendahl Mar 25, 2020
5705259
Merge branch 'master' into membership
Rotendahl Mar 25, 2020
74621a9
Spelling
Rotendahl Mar 25, 2020
5560f71
Updated deps
Rotendahl Mar 26, 2020
b0435ac
Merge branch 'membership' of github.com:Rotendahl/forenings_medlemmer…
Rotendahl Mar 28, 2020
a99b3f1
Merge branch 'quickpay_update' into membership
Rotendahl Mar 28, 2020
3419c88
Initial email
Rotendahl Mar 28, 2020
f5471ec
Merge branch 'master' into membership
Rotendahl Mar 28, 2020
f1a768e
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 28, 2020
aa72570
Cleaned imports and email template, and tests
Rotendahl Mar 29, 2020
62bddad
Merge branch 'membership' of github.com:Rotendahl/forenings_medlemmer…
Rotendahl Mar 29, 2020
16609bd
Cleaned gitignore
Rotendahl Mar 29, 2020
6e0895d
Almost Done
Rotendahl Mar 29, 2020
812af0d
Ran black and falke
Rotendahl Mar 29, 2020
4e39a09
Removed old test files
Rotendahl Mar 29, 2020
eb12da7
fixed untracked files
Rotendahl Mar 29, 2020
caf44a8
fixed untracked files
Rotendahl Mar 29, 2020
d0cd9e3
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 30, 2020
4c2bd15
Added test for github action debug
Rotendahl Mar 30, 2020
e632419
Next test step
Rotendahl Mar 30, 2020
429052c
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Mar 30, 2020
cdd19d3
Cleaned stuff
Rotendahl Mar 30, 2020
0383c97
Combined migrations
Rotendahl Mar 30, 2020
b89a5d6
Tried to remove redirect
Rotendahl Apr 6, 2020
2dbac2f
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Apr 6, 2020
4fb4d9b
Fixed test
Rotendahl Apr 6, 2020
1f83afa
Debug test
Rotendahl Apr 6, 2020
cee92b1
Saves screenshots
Rotendahl Apr 6, 2020
ea246da
Fixed test waits
Rotendahl Apr 6, 2020
3b8ecbe
Updated test
Rotendahl Apr 6, 2020
293dc21
Updated test
Rotendahl Apr 6, 2020
34c5c32
Fixed quickpay test
Rotendahl Apr 6, 2020
46951a3
Updated admin pages
Rotendahl Apr 6, 2020
491ea8b
Added docs and commands
Rotendahl Apr 6, 2020
80ad898
Removed unsued import
Rotendahl Apr 6, 2020
a6f18c0
CSS clean up
Rotendahl Apr 12, 2020
663564b
Merge branch 'master' into membership
Rotendahl Apr 13, 2020
ae2a799
Fixed spelling, renamed view, and fixed entrypage styling
Rotendahl Apr 13, 2020
fff01c9
Merge branch 'membership' of github.com:Rotendahl/forenings_medlemmer…
Rotendahl Apr 13, 2020
55adafe
Removed unibeautify
Rotendahl Apr 13, 2020
ab5f136
Spelling
Rotendahl Apr 13, 2020
d287504
Text correction
Rotendahl Apr 13, 2020
44b564d
Fjernet et S
Rotendahl Apr 13, 2020
eb33291
Updated comments
Rotendahl Apr 15, 2020
a380571
Merge branch 'master' into membership
Rotendahl Apr 17, 2020
abdea3a
Merge branch 'master' into membership
Rotendahl Apr 20, 2020
e07880c
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Apr 20, 2020
75b1313
Fixed factories
Rotendahl Apr 20, 2020
1c804d0
Removed jobs change
Rotendahl Apr 20, 2020
ee1125b
Unran isort
Rotendahl Apr 20, 2020
f67b10a
Removed JS comments
Rotendahl Apr 20, 2020
2f6f7ec
Merge branch 'master' into membership
Rotendahl Apr 27, 2020
1b5d5ee
Fixed merge
Rotendahl Apr 28, 2020
0cc2bbe
Merge branch 'master' of https://github.com/CodingPirates/forenings_m…
Rotendahl Jul 14, 2020
347785e
Fixed migrations
Rotendahl Jul 14, 2020
d39110f
ran black
Rotendahl Jul 14, 2020
8fd77dc
Merge branch 'master' into membership
Rotendahl Jul 28, 2020
b0d1cf7
Merge branch 'master' into membership
Rotendahl Aug 12, 2020
9052893
Merge branch 'master' into membership
Rotendahl Aug 31, 2020
d5b7f49
Merge branch 'master' into membership
Rotendahl Sep 2, 2020
54875f8
Merge branch 'master' into membership
Rotendahl Sep 21, 2020
91ffecd
Merge branch 'master' into membership
JondareHM Oct 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ You are more than welcome to contribute to the system. This guide documents how
- To create a super user for the admin interface you can run
`docker-compose run web ./manage.py createsuperuser`

- The see the emails we send (Payment confirmation etc.) run
Copy link
Member

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?

Copy link
Contributor Author

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

`docker-compose run web ./manage.py render_emails`
This will create a `generated_emails` folder with the html and text version
of the emails.

## Primary Frameworks/Systems used

- [Django][django]: The base web framework used. The link is to their great
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ jobs:
with:
name: UML_diagram.png
path: UML

- name: Create and render emails
run: docker-compose run web ./manage.py render_emails
- uses: actions/upload-artifact@v1
with:
name: rendered_emails
path: ./generated_emails
11 changes: 1 addition & 10 deletions .gitignore
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
19 changes: 0 additions & 19 deletions .unibeautifyrc.yml

This file was deleted.

4 changes: 3 additions & 1 deletion forenings_medlemmer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skal denne hardcodes? Kan vi ikke gemme værdien i environment-filen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Men kan fint smide den i .env

QUICKPAY_API_KEY = os.environ["QUICKPAY_API_KEY"]
QUICKPAY_PRIVATE_KEY = os.environ["QUICKPAY_PRIVATE_KEY"]
PAYMENT_ID_PREFIX = env.str("PAYMENT_ID_PREFIX")
Expand All @@ -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 = "/"
6 changes: 6 additions & 0 deletions members/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
Union,
Volunteer,
Member,
Membership,
Activity,
ActivityInvite,
ActivityParticipant,
Family,
EmailItem,
Payment,
PayableItem,
Equipment,
EquipmentLoan,
EmailTemplate,
Expand All @@ -38,6 +40,8 @@
from .member_admin import MemberAdmin
from .payment_admin import PaymentAdmin
from .activity_admin import ActivityAdmin
from .membership_admin import MembershipAdmin
from .payable_item_admin import PayableItemAdmin

admin.site.site_header = "Coding Pirates Medlemsdatabase"
admin.site.index_title = "Afdelings admin"
Expand All @@ -47,8 +51,10 @@
admin.site.register(Union, UnionAdmin)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.register(PayableItem, PayableItemAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Member, MemberAdmin)
admin.site.register(Membership, MembershipAdmin)
admin.site.register(Payment, PaymentAdmin)
admin.site.register(Activity, ActivityAdmin)
admin.site.register(EmailTemplate)
Expand Down
16 changes: 16 additions & 0 deletions members/admin/membership_admin.py
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Senere skal der laves sådan at man filterer på om de er betalt osv.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Det kræver lidt ekstra arbejde, men det kan vi fint.
Jeg tænker vi skal tilføje det som en seperat issue og en feature der kommer senere.

31 changes: 31 additions & 0 deletions members/admin/payable_item_admin.py
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

7 changes: 7 additions & 0 deletions members/admin/union_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def get_queryset(self, request):
)
},
),
(
"Kontingent",
{
"fields": ("membership_price_ore",),
"description": "Sæt kontingent for at blive medlem af jeres forening",
},
),
(
"Info",
{
Expand Down
2 changes: 2 additions & 0 deletions members/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
from .admin_signup_form import adminSignupForm
from .activity_signup_form import ActivitySignupForm
from .activity_invite_decline_form import ActivivtyInviteDeclineForm
from .membership_form import MembershipForm

__all__ = [
ActivivtyInviteDeclineForm,
ActivitySignupForm,
PersonForm,
signupForm,
MembershipForm,
vol_signupForm,
adminSignupForm,
]
22 changes: 22 additions & 0 deletions members/forms/membership_form.py
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
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"]
)
18 changes: 0 additions & 18 deletions members/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
EmailTemplate,
ActivityParticipant,
Payment,
Person,
Family,
)

Expand Down Expand Up @@ -59,23 +58,6 @@ def do(self):
curEmail.send()


class UpdateDawaData(CronJobBase):
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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"]
Expand Down
2 changes: 1 addition & 1 deletion members/management/commands/dump_public_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ændrer rækkefølgen da det ellers ikke duer



class Command(BaseCommand):
Expand Down
2 changes: 1 addition & 1 deletion members/management/commands/get_live_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import requests
import shutil

from dump_public_data import MODELS_TO_DUMP as MODELS_TO_LOAD
from .dump_public_data import MODELS_TO_DUMP as MODELS_TO_LOAD


class Command(BaseCommand):
Expand Down
28 changes: 28 additions & 0 deletions members/management/commands/render_emails.py
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En command der laver de mails der bliver sendt ud.
Tanken er at man så nemmere kan se hvad der bliver sendt uden at skulle ind i admin og lave et setup

10 changes: 10 additions & 0 deletions members/management/commands/send_emails.py
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()
49 changes: 0 additions & 49 deletions members/migrations/0010_move_address_to_union.py

This file was deleted.

2 changes: 1 addition & 1 deletion members/migrations/0011_adminuserinformation_unions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Migration(migrations.Migration):

dependencies = [
("members", "0010_move_address_to_union"),
("members", "0009_union_address"),
]

operations = [
Expand Down
Loading