-
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
Features/finanskonto for foreninger #1126
Changes from 5 commits
0b5a394
e73e0f8
aea582a
b973602
cbe98b3
bc58e93
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 | ||
---|---|---|---|---|
|
@@ -99,6 +99,81 @@ class UnionAdmin(admin.ModelAdmin): | |||
|
||||
actions = ["export_csv_union_info"] | ||||
|
||||
def get_fieldsets(self, request, obj=None): | ||||
# 20241113: https://stackoverflow.com/questions/16102222/djangoremove-superuser-checkbox-from-django-admin-panel-when-login-staff-users | ||||
|
||||
if not obj: | ||||
print("not obj") | ||||
return self.add_fieldsets | ||||
|
||||
info_fields = ( | ||||
"bank_main_org", | ||||
"bank_account", | ||||
"statues", | ||||
"founded_at", | ||||
"closed_at", | ||||
"gl_account", | ||||
) | ||||
|
||||
if not request.user.has_perm("members.showledgeraccount"): | ||||
print("no perm") | ||||
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. Tænker denne også kan fjernes?
Suggested change
|
||||
info_fields = ( | ||||
"bank_main_org", | ||||
"bank_account", | ||||
"statues", | ||||
"founded_at", | ||||
"closed_at", | ||||
) | ||||
|
||||
print(f"info:{info_fields}") | ||||
|
||||
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
Suggested change
|
||||
return [ | ||||
( | ||||
"Navn og Adresse", | ||||
{ | ||||
"fields": ("name", "email", "address"), | ||||
"description": "<p>Udfyld navnet på foreningen (f.eks København, \ | ||||
vestjylland) og adressen<p>", | ||||
}, | ||||
), | ||||
( | ||||
"Bestyrelsen nye felter", | ||||
{ | ||||
"fields": ( | ||||
"chairman", | ||||
"second_chair", | ||||
"cashier", | ||||
"secretary", | ||||
"board_members", | ||||
) | ||||
}, | ||||
), | ||||
( | ||||
"Bestyrelsen gamle felter", | ||||
{ | ||||
"fields": ( | ||||
"chairman_old", | ||||
"chairman_email_old", | ||||
"second_chair_old", | ||||
"second_chair_email_old", | ||||
"cashier_old", | ||||
"cashier_email_old", | ||||
"secretary_old", | ||||
"secretary_email_old", | ||||
"board_members_old", | ||||
) | ||||
}, | ||||
), | ||||
( | ||||
"Info", | ||||
{ | ||||
"fields": info_fields, | ||||
"description": "Indsæt et link til jeres vedtægter, hvornår I er stiftet (har holdt stiftende \ | ||||
generalforsamling) og jeres bankkonto hvis I har sådan en til foreningen.", | ||||
}, | ||||
), | ||||
] | ||||
|
||||
# Solution found on https://stackoverflow.com/questions/57056994/django-model-form-with-only-view-permission-puts-all-fields-on-exclude | ||||
# formfield_for_foreignkey described in documentation here: https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey | ||||
def formfield_for_foreignkey(self, db_field, request, **kwargs): | ||||
|
@@ -121,59 +196,6 @@ def get_queryset(self, request): | |||
return qs | ||||
return qs.filter(adminuserinformation__user=request.user) | ||||
|
||||
fieldsets = [ | ||||
( | ||||
"Navn og Adresse", | ||||
{ | ||||
"fields": ("name", "email", "address"), | ||||
"description": "<p>Udfyld navnet på foreningen (f.eks København, \ | ||||
vestjylland) og adressen<p>", | ||||
}, | ||||
), | ||||
( | ||||
"Bestyrelsen nye felter", | ||||
{ | ||||
"fields": ( | ||||
"chairman", | ||||
"second_chair", | ||||
"cashier", | ||||
"secretary", | ||||
"board_members", | ||||
) | ||||
}, | ||||
), | ||||
( | ||||
"Bestyrelsen gamle felter", | ||||
{ | ||||
"fields": ( | ||||
"chairman_old", | ||||
"chairman_email_old", | ||||
"second_chair_old", | ||||
"second_chair_email_old", | ||||
"cashier_old", | ||||
"cashier_email_old", | ||||
"secretary_old", | ||||
"secretary_email_old", | ||||
"board_members_old", | ||||
) | ||||
}, | ||||
), | ||||
( | ||||
"Info", | ||||
{ | ||||
"fields": ( | ||||
"bank_main_org", | ||||
"bank_account", | ||||
"statues", | ||||
"founded_at", | ||||
"closed_at", | ||||
), | ||||
"description": "Indsæt et link til jeres vedtægter, hvornår I er stiftet (har holdt stiftende \ | ||||
generalforsamling) og jeres bankkonto hvis I har sådan en til foreningen.", | ||||
}, | ||||
), | ||||
] | ||||
|
||||
def union_link(self, item): | ||||
url = reverse("admin:members_union_change", args=[item.id]) | ||||
link = '<a href="%s">%s</a>' % (url, escape(item.name)) | ||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
# Generated by Django 4.2.11 on 2024-11-13 19:56 | ||||||
|
||||||
import django.core.validators | ||||||
from django.db import migrations, models | ||||||
|
||||||
|
||||||
class Migration(migrations.Migration): | ||||||
|
||||||
dependencies = [ | ||||||
("members", "0057_municipality"), | ||||||
] | ||||||
|
||||||
operations = [ | ||||||
migrations.AlterModelOptions( | ||||||
name="union", | ||||||
options={ | ||||||
"ordering": ["name"], | ||||||
"permissions": ( | ||||||
("view_all_unions", "Can view all Foreninger"), | ||||||
("showledgeraccount", "Show General Ledger Account"), | ||||||
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. Bare for at være konsistent med andre permission definitions?
Suggested change
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. Der findes en senere migration hvor det ændres til det. |
||||||
), | ||||||
"verbose_name": "Forening", | ||||||
"verbose_name_plural": "Foreninger", | ||||||
}, | ||||||
), | ||||||
migrations.AddField( | ||||||
model_name="union", | ||||||
name="gl_account", | ||||||
field=models.CharField( | ||||||
blank=True, | ||||||
help_text="Kontonummer i formatet 1234", | ||||||
max_length=4, | ||||||
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. Har vi bekræftet med bogholder at vi max vil have 4 tegn i kontonumre? 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 var kravet som Anders har angivet |
||||||
validators=[ | ||||||
django.core.validators.RegexValidator( | ||||||
message="Indtast kontonummer i det rigtige format.", | ||||||
regex="^[0-9]{4}", | ||||||
) | ||||||
], | ||||||
verbose_name="Finanskonto:", | ||||||
), | ||||||
), | ||||||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 4.2.11 on 2024-11-13 20:11 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
( | ||
"members", | ||
"0058_alter_municipality_options_remove_municipality_email_and_more", | ||
), | ||
("members", "0058_alter_union_options_union_gl_account"), | ||
] | ||
|
||
operations = [] |
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.
Ser ud til at være en debug-ting?