Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Feature/yc 785 #903

Closed
wants to merge 173 commits into from
Closed
Show file tree
Hide file tree
Changes from 166 commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
3e29d29
Initial work on 'emoluments' for polcons.
nicolas-heigvd Dec 7, 2023
a83166c
Add table and update view + minor fixes in models and form.
nicolas-heigvd Dec 8, 2023
6c3407d
Update date widget for Prestations.
nicolas-heigvd Dec 8, 2023
5eeeaf2
Update settings: add default prestation price.
nicolas-heigvd Dec 13, 2023
a52a582
Update payment models.
nicolas-heigvd Dec 13, 2023
bbc0763
Update submission form.
nicolas-heigvd Dec 13, 2023
b9c50e9
Merge branch 'develop' into feature/YC-785
nicolas-heigvd Dec 13, 2023
7be45ad
Add prestation_price to the AdministrativeEntity accounts/model.
nicolas-heigvd Dec 13, 2023
4bb6cc4
Add new entry in AdministrativeEntityAdmin.
nicolas-heigvd Dec 13, 2023
a9b3666
Add new entry 'administrative_entity' in list_display and search_fiel…
nicolas-heigvd Dec 13, 2023
03e6248
Update submission form.
nicolas-heigvd Dec 13, 2023
e8ef359
Update dev compose file.
nicolas-heigvd Dec 14, 2023
a4e1df6
Update payement models; add administrative_entity and permit_departme…
nicolas-heigvd Dec 14, 2023
e263cc9
Add new permission 'has_permission_to_add_prestations'.
nicolas-heigvd Dec 14, 2023
cb55c82
Add new action fields to PrestationTable.
nicolas-heigvd Dec 14, 2023
82a58b6
Add new url /prestations
nicolas-heigvd Dec 14, 2023
d7ada55
Remove for from _submission_actions in order to keep it an other file.
nicolas-heigvd Dec 14, 2023
3b7877f
Update dev Compose file.
nicolas-heigvd Dec 15, 2023
cfb5ccd
Add new statuses for the ability to add prestations and remove unused…
nicolas-heigvd Dec 15, 2023
b0de9dc
Formatting
nicolas-heigvd Dec 15, 2023
40dc4af
Add new function 'create_new_submission_prestation' to create a new p…
nicolas-heigvd Dec 15, 2023
f06d896
Update LC_MESSAGES.
nicolas-heigvd Dec 15, 2023
8ec4826
Update submissions templates related to prestations.
nicolas-heigvd Dec 15, 2023
3060a09
Update _submission_actions template.
nicolas-heigvd Dec 15, 2023
ee97980
Update shortcuts.
nicolas-heigvd Dec 15, 2023
8f33c72
Add empty_text to prestation table.
nicolas-heigvd Dec 19, 2023
a30df90
Update _submission_actions template.
nicolas-heigvd Dec 19, 2023
a343fbc
Minor fix.
nicolas-heigvd Dec 19, 2023
fb31870
Minor fix.
nicolas-heigvd Dec 19, 2023
9dc29a7
Update urls; add a route for editing services fees.
nicolas-heigvd Dec 19, 2023
28c781d
Update messages.
nicolas-heigvd Dec 19, 2023
d3d1988
Remove comments.
nicolas-heigvd Dec 19, 2023
6cfd5c4
Major update:
nicolas-heigvd Dec 19, 2023
a9ff4ac
Update locale.
nicolas-heigvd Dec 19, 2023
9c7872d
Add reset script for convenience.
nicolas-heigvd Dec 19, 2023
549d5d4
Minor fix.
nicolas-heigvd Dec 19, 2023
8d0d5ad
Minor fix.
nicolas-heigvd Dec 19, 2023
b9fce94
Update ServiceFeesForm in forms.py.
nicolas-heigvd Dec 27, 2023
42f95ad
Fix agenda_visible variable default value.
nicolas-heigvd Dec 27, 2023
ab7d4a0
Update submission model: add an action for updating a service fee.
nicolas-heigvd Dec 27, 2023
464262f
Update urls.py add routes for CRUD operation on service fees.
nicolas-heigvd Dec 27, 2023
d13499a
Update ServiceFees and ServicesFeesType models.
nicolas-heigvd Dec 27, 2023
cc5f52c
Update tables.py: add permit_department column.
nicolas-heigvd Dec 27, 2023
b83dc75
Rename service fee creation template to fit CRUD naming.
nicolas-heigvd Dec 27, 2023
44e1a7b
Update permissions for creating a service fee and add permission for …
nicolas-heigvd Dec 27, 2023
f8563ed
Update shortcuts.py: add function to get services fee for user or 404.
nicolas-heigvd Dec 27, 2023
e2ffc9d
Minor fix on _submission_actions template.
nicolas-heigvd Dec 27, 2023
6bb6211
Update logging capabilities.
nicolas-heigvd Dec 27, 2023
a1fc450
Minor fix in reset script for development.
nicolas-heigvd Dec 27, 2023
3421b11
Update locale.
nicolas-heigvd Dec 27, 2023
c73d922
Update views.py: add some view to update and delete service fees.
nicolas-heigvd Dec 27, 2023
8c167eb
Add templates for deleting and updating service fees.
nicolas-heigvd Dec 27, 2023
3264cd3
Add table template for editing and deleting service fees.
nicolas-heigvd Dec 27, 2023
9a21378
Merge branch 'develop' into feature/YC-785
nicolas-heigvd Dec 27, 2023
6cb2b97
Add condition on db service in dev Compose file.
nicolas-heigvd Dec 28, 2023
15c3c0b
Minor fix on AdministrativeEntity account model.
nicolas-heigvd Dec 28, 2023
2507544
Get pricing from administrative_entity in ServicesFees model.
nicolas-heigvd Dec 28, 2023
624062d
Minor fix.
nicolas-heigvd Dec 28, 2023
e79439a
Upgrade fixturize data.
nicolas-heigvd Dec 28, 2023
a3445f9
Minor fix.
nicolas-heigvd Dec 28, 2023
55541b3
Minor: fix visibility of 'services_fees_type' in ServicesFeesForm.
nicolas-heigvd Dec 28, 2023
22f7377
Minor fix.
nicolas-heigvd Dec 28, 2023
064c59f
Code cleaning.
nicolas-heigvd Jan 4, 2024
b4a7d7d
Code cleaning.
nicolas-heigvd Jan 4, 2024
a9edb6e
Upgrade the get_service_fees() method to get_service_fees_for_user().
nicolas-heigvd Jan 4, 2024
21d127d
Code cleaning.
nicolas-heigvd Jan 4, 2024
882bc3d
Add permission to delete a service fee.
nicolas-heigvd Jan 4, 2024
3083f01
Update locale.
nicolas-heigvd Jan 4, 2024
93ed9cd
Update locale. Switch back main language to fr.
nicolas-heigvd Jan 8, 2024
661d7b7
Update base_generic.html. Add timer script to display info messages.
nicolas-heigvd Jan 8, 2024
746285e
Update account admin.
nicolas-heigvd Jan 8, 2024
1d49630
Update account model: add min_cfc2_price and services_fees_hourly_rat…
nicolas-heigvd Jan 8, 2024
99fafb0
Add message timer script.
nicolas-heigvd Jan 8, 2024
79a1673
Add fixed is_fixed_price field to ServicesFeesTypeAdmin.
nicolas-heigvd Jan 8, 2024
4e578d1
Add SubmissionCFC2Price model in payements.
nicolas-heigvd Jan 8, 2024
f2d1adf
Minor fix.
nicolas-heigvd Jan 8, 2024
664aa3f
Minor fix.
nicolas-heigvd Jan 8, 2024
1208b83
Add action to manage CFC 2 amount in the Submission model.
nicolas-heigvd Jan 8, 2024
6b07d32
Minor fix.
nicolas-heigvd Jan 8, 2024
e06cbba
Minor fix.
nicolas-heigvd Jan 8, 2024
4fed15a
Minor fix.
nicolas-heigvd Jan 8, 2024
61529c0
Minor fix.
nicolas-heigvd Jan 8, 2024
2c81866
Minor update in settings.
nicolas-heigvd Jan 9, 2024
c653248
Add permissions to create, update and delete service fees for all 3 m…
nicolas-heigvd Jan 9, 2024
097ac97
Add permissions to create, update and delete service fees in Submissi…
nicolas-heigvd Jan 9, 2024
eb24681
Update urlpatterns for a clearer separation.
nicolas-heigvd Jan 9, 2024
5317499
Minor fix in ServicesFees model.
nicolas-heigvd Jan 9, 2024
5c6c5f6
Update permissions to allow validators to create, update and delete s…
nicolas-heigvd Jan 9, 2024
ddf83d3
Update submission forms: add CFC2Form + fix set form in readonly when…
nicolas-heigvd Jan 9, 2024
98db1b1
Update service fees html templates.
nicolas-heigvd Jan 9, 2024
cca0771
Major refactor of the service fees views.
nicolas-heigvd Jan 9, 2024
330e3d7
Minor fix.
nicolas-heigvd Jan 9, 2024
5e00630
Restore .pre-commit-config.yaml.
nicolas-heigvd Jan 9, 2024
745f813
Minor fix.
nicolas-heigvd Jan 9, 2024
6253f96
Remove unnecessary code.
nicolas-heigvd Jan 9, 2024
65ff162
Code cleaning.
nicolas-heigvd Jan 9, 2024
7b9ce80
Update service fees views and templates: add a cancel button on updat…
nicolas-heigvd Jan 9, 2024
6b3acff
Retore dev Compose file.
nicolas-heigvd Jan 9, 2024
b33268f
Add Cancel button everywhere in service fees views.
nicolas-heigvd Jan 9, 2024
f6de92b
Update locale.
nicolas-heigvd Jan 9, 2024
b3ca77c
UX/UI enhancements.
nicolas-heigvd Jan 9, 2024
38c8385
Minor fix.
nicolas-heigvd Jan 9, 2024
34dc61f
Update main.css.
nicolas-heigvd Jan 9, 2024
d81c735
Code cleaning.
nicolas-heigvd Jan 9, 2024
ea41a16
Update submission model: remove unnecessary constants.
nicolas-heigvd Jan 9, 2024
ce983e0
Update tables: add footer with sum over the amount of the services fees.
nicolas-heigvd Jan 9, 2024
064a54f
Minor updates on service fees templates.
nicolas-heigvd Jan 9, 2024
3a2a83c
Fix locale.
nicolas-heigvd Jan 10, 2024
3979bf3
Fix error in ServicesFeesTable.
nicolas-heigvd Jan 10, 2024
2565ac6
Minor fix.
nicolas-heigvd Jan 10, 2024
202496c
Update ServicesFeesTable: add sum for timedelta.
nicolas-heigvd Jan 10, 2024
a2a57f8
Formatting.
nicolas-heigvd Jan 10, 2024
533106a
Add convenience functions.
nicolas-heigvd Jan 10, 2024
f62081d
Minor fix in ServicesFeesForm.
nicolas-heigvd Jan 10, 2024
13dbfc4
Update *_submission_service_fees views to autofill 'provided_by' when…
nicolas-heigvd Jan 10, 2024
d3c81b9
Update submission views and forms; move logic about the 'provided_by'…
nicolas-heigvd Jan 10, 2024
f179a14
Update locale.
nicolas-heigvd Jan 10, 2024
f9ccb45
UX/UI update on buttons.
nicolas-heigvd Jan 10, 2024
d88dfe0
Add is_fixed_priced boolean field to ServicesFees model.
nicolas-heigvd Jan 10, 2024
33b854b
Major update: add the abilit to add a fix price service fee.
nicolas-heigvd Jan 11, 2024
230a2f9
Minor update.
nicolas-heigvd Jan 12, 2024
10bbbd4
Harmonize service fees templates.
nicolas-heigvd Jan 12, 2024
46f6694
Minor update.
nicolas-heigvd Jan 12, 2024
78cc12c
Minor update.
nicolas-heigvd Jan 12, 2024
b64bd7a
Update locale.
nicolas-heigvd Jan 12, 2024
03ad529
Make get_service_fee_for_user_or_404 function more robust.
nicolas-heigvd Jan 12, 2024
867676e
Move some logic from service fees related views to ServicesFeesForm.
nicolas-heigvd Jan 12, 2024
13fda27
Add new generic template for services fees actions.
nicolas-heigvd Jan 12, 2024
5296d62
Add new generic view and url for services fees actions.
nicolas-heigvd Jan 12, 2024
edb6ff5
Clean ServicesFeesForm.
nicolas-heigvd Jan 15, 2024
83a619c
Move mode from URL to query params. Add action to query params.
nicolas-heigvd Jan 15, 2024
023c5a9
Update template to include the CREATE action.
nicolas-heigvd Jan 15, 2024
d08b37a
Minor fix.
nicolas-heigvd Jan 15, 2024
8c2bb07
Update urls: remove CRUD verbs from endpoints.
nicolas-heigvd Jan 15, 2024
f887238
Remove deprecated code: add the ability to CREATE a new service fee i…
nicolas-heigvd Jan 15, 2024
5e7b777
Remove deprecated templates.
nicolas-heigvd Jan 15, 2024
2f984bd
Add verbosity.
nicolas-heigvd Jan 15, 2024
34cd7fa
Add missing form for create action in template.
nicolas-heigvd Jan 15, 2024
4a6dd40
Add some missing condition checks for create action in submission_ser…
nicolas-heigvd Jan 15, 2024
9fd0133
Minor fix.
nicolas-heigvd Jan 15, 2024
03949e1
Replace detailed permissions in Submission model.
nicolas-heigvd Jan 15, 2024
609910d
Remove unncessary field and minor fix.
nicolas-heigvd Jan 15, 2024
a679b89
Replace detailed permissions with a unique generic one for managing s…
nicolas-heigvd Jan 15, 2024
1ae4d71
Add inline for ServicesFees in the account admin in order to manage s…
nicolas-heigvd Jan 15, 2024
1c46c22
Replace detailed permissions by a unique and more generic one for man…
nicolas-heigvd Jan 15, 2024
3b12a2c
Add verbosity.
nicolas-heigvd Jan 15, 2024
c8b6c25
Update locale.
nicolas-heigvd Jan 16, 2024
a134a9d
Minor fix.
nicolas-heigvd Jan 16, 2024
0debff6
Override form for ServicesFeesTypeAdmin using ServicesFeesTypeAdminForm.
nicolas-heigvd Jan 16, 2024
31c5d81
Add statuses to get_service_fee().
nicolas-heigvd Jan 16, 2024
da3f1da
Update locale.
nicolas-heigvd Jan 16, 2024
8338544
Minor update.
nicolas-heigvd Jan 16, 2024
ab9fe28
Minor fix.
nicolas-heigvd Jan 16, 2024
e7c3c5e
Update ServicesFeesType() model; set a fix_price attribute.
nicolas-heigvd Jan 16, 2024
45ca45d
Add fix_price to ServicesFeesTypeAdminForm and ServicesFeesTypeAdmin.
nicolas-heigvd Jan 16, 2024
4481aef
Add context data to submission_service_fees view.
nicolas-heigvd Jan 16, 2024
464e342
Add icon for ServicesFeesType in jazzmin admin.
nicolas-heigvd Jan 17, 2024
9f386b7
Use a global settings for the currency of service fees.
nicolas-heigvd Jan 17, 2024
0d0e61c
Cleaning.
nicolas-heigvd Jan 17, 2024
49f8237
Update monetary_amount in the form based on the service fee type defi…
nicolas-heigvd Jan 17, 2024
ae85a1d
Update locale.
nicolas-heigvd Jan 17, 2024
618a3c3
Add migrations files.
nicolas-heigvd Jan 17, 2024
b87dbb2
Merge branch 'develop' into feature/YC-785
nicolas-heigvd Jan 17, 2024
655932d
Update migations.
nicolas-heigvd Jan 17, 2024
7296177
Fix _submission_actions template.
nicolas-heigvd Jan 17, 2024
263fe49
Merge branch 'develop' into feature/YC-785
nicolas-heigvd Jan 17, 2024
88c90ac
fixtures examples
monodo Jan 18, 2024
bc0d3ad
Bugfix models.AdministrativeEntity.MultipleObjectsReturned: get() ret…
nicolas-heigvd Jan 19, 2024
3825df7
Fix service fees related models and associated migration file.
nicolas-heigvd Jan 19, 2024
45839c3
Bug fixes.
nicolas-heigvd Jan 19, 2024
2c73866
Merge branch 'develop' into feature/YC-785
nicolas-heigvd Jan 19, 2024
3647258
Update fixtures.
nicolas-heigvd Jan 19, 2024
5f83796
Check permissions before displaying service fee tab.
nicolas-heigvd Jan 19, 2024
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
12 changes: 11 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ volumes:

services:
web:
# Uncomment those two lines for debug
#tty: true
#stdin_open: true
build:
args:
ENV: DEV
Expand All @@ -19,13 +22,20 @@ services:
- ./_dev_volumes/private_documents:/private_documents
- ./_dev_volumes/archive:/archive
depends_on:
- "postgres"
postgres:
condition: service_healthy
ports:
- "${DJANGO_DOCKER_PORT}:9000"

postgres:
image: postgis/postgis:13-3.2
restart: unless-stopped
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-U", "${PGUSER}" ]
interval: 5s
timeout: 10s
retries: 3
start_period: 10s
environment:
- POSTGRES_USER=${PGUSER}
- POSTGRES_PASSWORD=${PGPASSWORD}
Expand Down
1 change: 1 addition & 0 deletions geocity/admin_jazzmin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"reports.ComplementaryDocumentTypeForAdminSite": "fas fa-copy",
"submissions.Submission": "fas fa-search",
"submissions.SubmissionAmendField": "fas fa-list-alt",
"submissions.ServicesFeesType": "fas fa-file-invoice-dollar",
"submissions.SubmissionInquiry": "fas fa-calendar",
"taggit.Tag": "fas fa-bookmark",
},
Expand Down
33 changes: 25 additions & 8 deletions geocity/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from geocity.apps.accounts.models import AdministrativeEntity, UserProfile
from geocity.apps.reports.models import Report
from geocity.apps.submissions.models import Submission, SubmissionWorkflowStatus
from geocity.apps.submissions.payments.models import ServicesFeesType
from geocity.fields import GeometryWidget

from . import models, permissions_groups
Expand Down Expand Up @@ -67,6 +68,7 @@
</ul>
"""


# Allow a user belonging to integrator group to see only objects created by this group
def filter_for_user(user, qs):
if not user.is_superuser:
Expand Down Expand Up @@ -453,7 +455,6 @@ class Media:
css = {"all": ("css/admin/admin.css",)}

def clean_permissions(self):

permissions = self.cleaned_data["permissions"]
permissions_for_trusted_users = Permission.objects.filter(
codename__in=permissions_groups.AVAILABLE_FOR_INTEGRATOR_PERMISSION_CODENAMES
Expand Down Expand Up @@ -603,7 +604,6 @@ def get__sites_number(self, obj):
get__sites_number.short_description = _("Nombre de sites")

def get_queryset(self, request):

if request.user.is_superuser:
qs = Group.objects.all()
else:
Expand All @@ -627,14 +627,12 @@ def save_model(self, request, obj, form, change):
def formfield_for_manytomany(self, db_field, request, **kwargs):
# permissions that integrator role can grant to group
if db_field.name == "permissions":

if (
not request.user.is_superuser
and request.user.groups.get(
permit_department__is_integrator_admin=True
).pk
):

integrator_permissions = Permission.objects.filter(
codename__in=permissions_groups.AVAILABLE_FOR_INTEGRATOR_PERMISSION_CODENAMES
)
Expand All @@ -649,7 +647,6 @@ def label_from_instance(self, obj):


def get_sites_field(user):

qs = models.Site.objects.all()

if not user.is_superuser:
Expand Down Expand Up @@ -701,6 +698,7 @@ class Meta:
"signature_sheet",
"signature_sheet_description",
"additional_searchtext_for_address_field",
"services_fees_hourly_rate",
"geom",
"integrator",
]
Expand Down Expand Up @@ -759,9 +757,15 @@ class SubmissionWorkflowStatusInline(admin.TabularInline):
verbose_name_plural = _("Flux (complet par défaut)")


class ServicesFeesInline(IntegratorFilterMixin, admin.TabularInline):
model = ServicesFeesType
extra = 1
verbose_name = _("Type de prestation")
verbose_name_plural = _("Types de prestation")


@admin.register(models.AdministrativeEntityForAdminSite)
class AdministrativeEntityAdmin(IntegratorFilterMixin, admin.ModelAdmin):

fieldsets = (
(
None,
Expand Down Expand Up @@ -820,7 +824,20 @@ class AdministrativeEntityAdmin(IntegratorFilterMixin, admin.ModelAdmin):
),
},
),
(
_("Tarification des prestations"),
{
"fields": (
"services_fees_hourly_rate",
"min_cfc2_price",
),
"description": _(
"La tarification des prestations permet de saisir le tarif horaire de facturation des prestations pour l'entité administrative courante."
),
},
),
)

# Pass the user from ModelAdmin to ModelForm
def get_form(self, request, obj=None, **kwargs):
Form = super().get_form(request, obj, **kwargs)
Expand All @@ -835,6 +852,7 @@ def __new__(cls, *args, **kwargs):
change_form_template = "accounts/admin/administrative_entity_change.html"
form = AdministrativeEntityAdminForm
inlines = [
# ServicesFeesInline, # not working
SubmissionWorkflowStatusInline,
]
list_filter = [
Expand All @@ -851,6 +869,7 @@ def __new__(cls, *args, **kwargs):
"get_tags",
"get_is_single_form",
"get_sites",
"services_fees_hourly_rate",
]

def sortable_str(self, obj):
Expand Down Expand Up @@ -879,15 +898,13 @@ def get_is_single_form(self, obj):
get_is_single_form.admin_order_field = "is_single_form_submissions"

def formfield_for_foreignkey(self, db_field, request, **kwargs):

if db_field.name == "integrator":
kwargs["queryset"] = Group.objects.filter(
permit_department__is_integrator_admin=True,
)
return super().formfield_for_foreignkey(db_field, request, **kwargs)

def save_model(self, request, obj, form, change):

if not request.user.is_superuser:
obj.integrator = request.user.groups.get(
permit_department__is_integrator_admin=True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 4.2.8 on 2024-01-17 09:13

from decimal import Decimal

import djmoney.models.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("accounts", "0015_alter_siteprofile_integrator"),
]

operations = [
migrations.AddField(
model_name="administrativeentity",
name="min_cfc2_price",
field=djmoney.models.fields.MoneyField(
decimal_places=2,
default=Decimal("4000000.0"),
help_text="Montant CFC 2 minimal pour les demandes faites à l'entité administrative courante",
max_digits=12,
verbose_name="Montant CFC 2 minimal",
),
),
migrations.AddField(
model_name="administrativeentity",
name="min_cfc2_price_currency",
field=djmoney.models.fields.CurrencyField(
choices=[("CHF", "CHF .-"), ("EUR", "EUR €"), ("USD", "USD $")],
default="CHF",
editable=False,
max_length=3,
),
),
migrations.AddField(
model_name="administrativeentity",
name="services_fees_hourly_rate",
field=djmoney.models.fields.MoneyField(
decimal_places=2,
default=Decimal("0.0"),
help_text="Tarif horaire des prestations de l'entité administrative",
max_digits=12,
verbose_name="Tarif horaire",
),
),
migrations.AddField(
model_name="administrativeentity",
name="services_fees_hourly_rate_currency",
field=djmoney.models.fields.CurrencyField(
choices=[("CHF", "CHF .-"), ("EUR", "EUR €"), ("USD", "USD $")],
default="CHF",
editable=False,
max_length=3,
),
),
]
22 changes: 20 additions & 2 deletions geocity/apps/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.dispatch import receiver
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from djmoney.models.fields import MoneyField
from simple_history.models import HistoricalRecords
from taggit.managers import TaggableManager

Expand Down Expand Up @@ -322,7 +323,6 @@ class AdministrativeEntity(models.Model):
default=True,
help_text=_("Nécessaire pour l'utilisation du système de paiement en ligne"),
)

sites = models.ManyToManyField(
Site,
related_name="administrative_entity",
Expand All @@ -345,6 +345,25 @@ class AdministrativeEntity(models.Model):
signature_sheet_description = models.TextField(
_("Texte explicatif relatif au volet de transmission"), blank=True
)
min_cfc2_price = MoneyField(
decimal_places=2,
max_digits=12,
default_currency="CHF",
default=4e6,
verbose_name=_("Montant CFC 2 minimal"),
help_text=_(
"Montant CFC 2 minimal pour les demandes faites à l'entité administrative courante"
),
)
services_fees_hourly_rate = MoneyField(
decimal_places=2,
max_digits=12,
default_currency="CHF",
default=settings.DEFAULT_SERVICES_FEES_RATE,
verbose_name=_("Tarif horaire"),
help_text=_("Tarif horaire des prestations de l'entité administrative"),
)

objects = AdministrativeEntityManager()

class Meta:
Expand Down Expand Up @@ -599,7 +618,6 @@ class Meta:
verbose_name_plural = _("3.2 Consultation des auteurs")

def __str__(self):

return (
str(self.user.first_name) + " " + str(self.user.last_name)
if self.user
Expand Down
14 changes: 14 additions & 0 deletions geocity/apps/accounts/permissions_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"submissions": [
"submissionamendfield",
"submissionworkflowstatus",
"servicesfeestype",
],
"reports": [
"report",
Expand All @@ -28,6 +29,7 @@
"section",
"headerfooter",
],
# FIXME: get nested submissions.payments
}

# define permissions required by integrator role
Expand Down Expand Up @@ -62,16 +64,28 @@
"can_generate_pdf",
"can_refund_transactions",
"can_revert_refund_transactions",
"can_manage_service_fee",
# "create_service_fee",
# "update_service_fee",
# "delete_service_fee",
]

DEFAULT_PILOT_PERMISSION_CODENAMES = [
"read_submission",
"amend_submission",
"classify_submission",
"can_generate_pdf",
"can_manage_service_fee",
# "create_service_fee",
# "update_service_fee",
# "delete_service_fee",
]

DEFAULT_VALIDATOR_PERMISSION_CODENAMES = [
"read_submission",
"validate_submission",
"can_manage_service_fee",
# "create_service_fee",
# "update_service_fee",
# "delete_service_fee",
]
33 changes: 33 additions & 0 deletions geocity/apps/accounts/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,37 @@ def get_users_list_for_integrator_admin(user, remove_anonymous=False):
):
anonymous_users.append(user.pk)
qs = qs.exclude(pk__in=anonymous_users)

return qs


def is_backoffice_in_department(user, department):
"""
Check if user is backoffice for a given department (group)
a.k.a. administrative entity.
"""
current_user_groups_pk = user.groups.all().values_list("pk", flat=True)
# Find the group of this user and filter by is_backoffice
departments_of_the_current_user = models.PermitDepartment.objects.filter(
administrative_entity=department,
is_backoffice=True,
pk__in=current_user_groups_pk,
)

return any(current_user_groups_pk.intersection(departments_of_the_current_user))


def is_validator_in_department(user, department):
"""
Check if user is validator for a given department (group)
a.k.a. administrative entity.
"""
current_user_groups_pk = user.groups.all().values_list("pk", flat=True)
# Find the group of this user and filter by is_validator
departments_of_the_current_user = models.PermitDepartment.objects.filter(
administrative_entity=department,
is_validator=True,
pk__in=current_user_groups_pk,
)

return any(current_user_groups_pk.intersection(departments_of_the_current_user))
8 changes: 8 additions & 0 deletions geocity/apps/core/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ input:focus {
vertical-align: baseline;
}

.table tfoot {
font-weight: bold;
}

.page-item.active .page-link {
background-color: var(--primary-color);
border-color: var(--primary-color);
Expand Down Expand Up @@ -407,6 +411,10 @@ h5 {
color: crimson;
}

.fa-trash-white {
color: #ffffff;
}

.table-container {
overflow-x: visible;
}
Expand Down
8 changes: 8 additions & 0 deletions geocity/apps/core/static/js/messages_timer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Get all messages of the alert-success class
let info_messages = document.getElementsByClassName('alert-success');

setTimeout(function(){
for (let i = 0; i < info_messages.length; i ++) {
info_messages[i].setAttribute('style', 'display:none');
}
}, 4000);
Loading
Loading