-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: limit users based on alloted facilities
- Loading branch information
1 parent
659e71b
commit ad74c87
Showing
9 changed files
with
115 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from .base_forms import BaseModelForm | ||
from .common_forms import ( | ||
FacilityAttachmentForm, | ||
FacilityForm, | ||
FacilityUserForm, | ||
OrganisationForm, | ||
SystemForm, | ||
UserFacilityAllotmentForm, | ||
) | ||
|
||
__all__ = [ | ||
"BaseModelForm", | ||
"FacilityAttachmentForm", | ||
"FacilityForm", | ||
"FacilityUserForm", | ||
"OrganisationForm", | ||
"SystemForm", | ||
"UserFacilityAllotmentForm", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Submit | ||
from django.forms import ModelForm | ||
|
||
|
||
class BaseModelForm(ModelForm): | ||
"""Base form for the majority of model forms in the project.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.helper = FormHelper(self) | ||
self.helper.form_method = "post" | ||
self.helper.form_action = "" | ||
self.helper.add_input(Submit("submit", "Save")) | ||
self.helper.html5_required = True | ||
|
||
class Meta: | ||
exclude = ( | ||
"created", | ||
"updated", | ||
"created_by", | ||
"updated_by", | ||
"organisation", | ||
) |
33 changes: 7 additions & 26 deletions
33
fahari/common/forms.py → fahari/common/forms/common_forms.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Shared serializer module.""" | ||
from .base_serializers import BaseSerializer | ||
from .common_serializers import ( | ||
FacilitySerializer, | ||
FacilityUserSerializer, | ||
SystemSerializer, | ||
UserFacilityAllotmentSerializer, | ||
) | ||
from .mixins import AuditFieldsMixin, PartialResponseMixin | ||
|
||
__all__ = [ | ||
"AuditFieldsMixin", | ||
"BaseSerializer", | ||
"PartialResponseMixin", | ||
"FacilitySerializer", | ||
"FacilityUserSerializer", | ||
"SystemSerializer", | ||
"UserFacilityAllotmentSerializer", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Base serializers used in the project.""" | ||
import logging | ||
|
||
from rest_framework import serializers | ||
|
||
from .mixins import AuditFieldsMixin | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class BaseSerializer(AuditFieldsMixin): | ||
"""Base class intended for inheritance by 'regular' app serializers.""" | ||
|
||
url = serializers.URLField(source="get_absolute_url", read_only=True) | ||
|
||
class Meta: | ||
datatables_always_serialize = ( | ||
"id", | ||
"url", | ||
) |
18 changes: 3 additions & 15 deletions
18
fahari/common/serializers.py → .../common/serializers/common_serializers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters