Compare commits
No commits in common. "30f36060f304518f6cb737e91b1b865fe48b18c6" and "0e7c378d4aa96b2650f97641b4487140dea03efb" have entirely different histories.
30f36060f3
...
0e7c378d4a
@ -14,15 +14,13 @@ from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERV
|
||||
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_COMPENSATION_HANDLER_ID, \
|
||||
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
|
||||
CODELIST_COMPENSATION_FUNDING_ID, CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID
|
||||
from konova.management.commands.setup import BaseKonovaCommand
|
||||
|
||||
bool_map = {
|
||||
"true": True,
|
||||
"false": False,
|
||||
}
|
||||
|
||||
|
||||
class Command(BaseKonovaCommand):
|
||||
class Command(BaseCommand):
|
||||
help = "Performs test on collisions using the identifier generation"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
@ -103,4 +101,33 @@ class Command(BaseKonovaCommand):
|
||||
items=children,
|
||||
code_list=code_list,
|
||||
parent=code
|
||||
)
|
||||
)
|
||||
|
||||
def _break_line(self):
|
||||
""" Simply prints a line break
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.stdout.write("\n")
|
||||
|
||||
def _write_warning(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.WARNING(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
def _write_success(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
def _write_error(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.ERROR(
|
||||
txt
|
||||
)
|
||||
)
|
@ -76,6 +76,7 @@ class KonovaCodeList(models.Model):
|
||||
)
|
||||
codes = models.ManyToManyField(
|
||||
KonovaCode,
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Codes for this list",
|
||||
related_name="code_lists"
|
||||
|
@ -141,6 +141,7 @@ class AbstractCompensation(BaseObject):
|
||||
|
||||
fundings = models.ManyToManyField(
|
||||
KonovaCode,
|
||||
null=True,
|
||||
blank=True,
|
||||
limit_choices_to={
|
||||
"code_lists__in": [CODELIST_COMPENSATION_FUNDING_ID],
|
||||
|
@ -161,6 +161,7 @@ class LegalData(UuidModel):
|
||||
)
|
||||
laws = models.ManyToManyField(
|
||||
KonovaCode,
|
||||
null=True,
|
||||
blank=True,
|
||||
limit_choices_to={
|
||||
"code_lists__in": [CODELIST_LAW_ID],
|
||||
|
@ -14,6 +14,35 @@ from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES
|
||||
CODELIST_COMPENSATION_FUNDING_ID
|
||||
from compensation.models import EcoAccount
|
||||
from intervention.models import Intervention
|
||||
from organisation.models import Organisation
|
||||
|
||||
|
||||
class OrganisationAutocomplete(Select2QuerySetView):
|
||||
def get_queryset(self):
|
||||
if self.request.user.is_anonymous:
|
||||
return Organisation.objects.none()
|
||||
qs = Organisation.objects.all()
|
||||
if self.q:
|
||||
qs = qs.filter(name__icontains=self.q)
|
||||
qs = qs.order_by(
|
||||
"name"
|
||||
)
|
||||
return qs
|
||||
|
||||
|
||||
class NonOfficialOrganisationAutocomplete(Select2QuerySetView):
|
||||
def get_queryset(self):
|
||||
if self.request.user.is_anonymous:
|
||||
return Organisation.objects.none()
|
||||
qs = Organisation.objects.all()
|
||||
if self.q:
|
||||
qs = qs.filter(
|
||||
name__icontains=self.q,
|
||||
)
|
||||
qs = qs.order_by(
|
||||
"name"
|
||||
)
|
||||
return qs
|
||||
|
||||
|
||||
class EcoAccountAutocomplete(Select2QuerySetView):
|
||||
|
@ -8,64 +8,27 @@ Created on: 15.12.20
|
||||
from getpass import getpass
|
||||
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.core.management import BaseCommand, call_command
|
||||
from django.core.management import BaseCommand
|
||||
from django.db import transaction
|
||||
|
||||
from konova.management.commands.setup_data import GROUPS_DATA, USER_NOTIFICATIONS_NAMES
|
||||
from konova.management.commands.setup_data import TEST_ORGANISATION_DATA, GROUPS_DATA, USER_NOTIFICATIONS_NAMES
|
||||
from organisation.models import Organisation
|
||||
from user.enums import UserNotificationEnum
|
||||
from user.models import UserNotification
|
||||
|
||||
CREATED_TEMPLATE = "{} created"
|
||||
|
||||
|
||||
class BaseKonovaCommand(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
# Needs to be implemented in inheriting classes
|
||||
raise NotImplementedError
|
||||
|
||||
def _break_line(self):
|
||||
""" Simply prints a line break
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.stdout.write("\n")
|
||||
|
||||
def _write_warning(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.WARNING(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
def _write_success(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
def _write_error(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.ERROR(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class Command(BaseKonovaCommand):
|
||||
class Command(BaseCommand):
|
||||
help = "Initializes database with basic data"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
with transaction.atomic():
|
||||
self._init_superuser()
|
||||
self._init_test_organisation()
|
||||
self._init_default_groups()
|
||||
self._init_user_notifications()
|
||||
self._init_codelists()
|
||||
except KeyboardInterrupt:
|
||||
self._break_line()
|
||||
exit(-1)
|
||||
@ -99,6 +62,20 @@ class Command(BaseKonovaCommand):
|
||||
self._write_success("Superuser {} created".format(username))
|
||||
self._break_line()
|
||||
|
||||
def _init_test_organisation(self):
|
||||
""" Creates test organisations from predefined data
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self._write_warning("--- Organisations ---")
|
||||
for org in TEST_ORGANISATION_DATA:
|
||||
db_org = Organisation.objects.get_or_create(
|
||||
**org
|
||||
)[0]
|
||||
self._write_success(CREATED_TEMPLATE.format(db_org.name))
|
||||
self._break_line()
|
||||
|
||||
def _init_default_groups(self):
|
||||
""" Creates the default groups for konova:
|
||||
* Group default
|
||||
@ -135,12 +112,31 @@ class Command(BaseKonovaCommand):
|
||||
|
||||
self._break_line()
|
||||
|
||||
def _init_codelists(self):
|
||||
""" Calls the 'update_codelist' command found in codelist app
|
||||
def _break_line(self):
|
||||
""" Simply prints a line break
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
return call_command(
|
||||
'update_codelist'
|
||||
self.stdout.write("\n")
|
||||
|
||||
def _write_warning(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.WARNING(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
def _write_success(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
txt
|
||||
)
|
||||
)
|
||||
|
||||
def _write_error(self, txt: str):
|
||||
self.stdout.write(
|
||||
self.style.ERROR(
|
||||
txt
|
||||
)
|
||||
)
|
@ -9,6 +9,21 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
|
||||
TEST_ORGANISATION_DATA = [
|
||||
{
|
||||
"name": "Test_Official_1",
|
||||
},
|
||||
{
|
||||
"name": "Test_Official_2",
|
||||
},
|
||||
{
|
||||
"name": "Test_NGO_1",
|
||||
},
|
||||
{
|
||||
"name": "Test_Company_1",
|
||||
},
|
||||
]
|
||||
|
||||
GROUPS_DATA = [
|
||||
{
|
||||
"name": DEFAULT_GROUP,
|
||||
|
@ -65,6 +65,7 @@ INSTALLED_APPS = [
|
||||
'konova',
|
||||
'compensation',
|
||||
'intervention',
|
||||
'organisation',
|
||||
'news',
|
||||
'user',
|
||||
'ema',
|
||||
|
@ -17,7 +17,7 @@ import debug_toolbar
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
from konova.autocompletes import EcoAccountAutocomplete, \
|
||||
from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete, EcoAccountAutocomplete, \
|
||||
InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete, LawCodeAutocomplete, \
|
||||
RegistrationOfficeCodeAutocomplete, ConservationOfficeCodeAutocomplete, ProcessTypeCodeAutocomplete, \
|
||||
CompensationFundingCodeAutocomplete
|
||||
@ -34,6 +34,7 @@ urlpatterns = [
|
||||
path('intervention/', include("intervention.urls")),
|
||||
path('compensation/', include("compensation.urls")),
|
||||
path('ema/', include("ema.urls")),
|
||||
path('organisation/', include("organisation.urls")),
|
||||
path('user/', include("user.urls")),
|
||||
path('news/', include("news.urls")),
|
||||
path('news/', include("codelist.urls")),
|
||||
@ -42,6 +43,8 @@ urlpatterns = [
|
||||
path('deadline/<id>/remove', remove_deadline_view, name="deadline-remove"),
|
||||
|
||||
# Autocomplete paths for all apps
|
||||
path("atcmplt/orgs", OrganisationAutocomplete.as_view(), name="orgs-autocomplete"),
|
||||
path("atcmplt/orgs/other", NonOfficialOrganisationAutocomplete.as_view(), name="other-orgs-autocomplete"),
|
||||
path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"),
|
||||
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
|
||||
path("atcmplt/codes/comp/action", CompensationActionCodeAutocomplete.as_view(), name="codes-compensation-action-autocomplete"),
|
||||
|
0
organisation/__init__.py
Normal file
0
organisation/__init__.py
Normal file
13
organisation/admin.py
Normal file
13
organisation/admin.py
Normal file
@ -0,0 +1,13 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from organisation.models import Organisation
|
||||
|
||||
|
||||
class OrganisationAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"name",
|
||||
"created",
|
||||
]
|
||||
|
||||
|
||||
admin.site.register(Organisation, OrganisationAdmin)
|
5
organisation/apps.py
Normal file
5
organisation/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class OrganisationConfig(AppConfig):
|
||||
name = 'organisation'
|
8
organisation/enums.py
Normal file
8
organisation/enums.py
Normal file
@ -0,0 +1,8 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 07.12.20
|
||||
|
||||
"""
|
||||
from konova.enums import BaseEnum
|
16
organisation/models.py
Normal file
16
organisation/models.py
Normal file
@ -0,0 +1,16 @@
|
||||
from django.db import models
|
||||
|
||||
from konova.models import BaseResource
|
||||
|
||||
|
||||
class Organisation(BaseResource):
|
||||
name = models.CharField(max_length=500, unique=True)
|
||||
address = models.CharField(max_length=500, null=True, blank=True)
|
||||
city = models.CharField(max_length=500, null=True, blank=True)
|
||||
postal_code = models.CharField(max_length=100, null=True, blank=True)
|
||||
phone = models.CharField(max_length=500, null=True, blank=True)
|
||||
email = models.EmailField(max_length=500, null=True, blank=True)
|
||||
facsimile = models.CharField(max_length=500, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
8
organisation/settings.py
Normal file
8
organisation/settings.py
Normal file
@ -0,0 +1,8 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 07.12.20
|
||||
|
||||
"""
|
||||
from django.utils.translation import gettext_lazy as _
|
3
organisation/tests.py
Normal file
3
organisation/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
12
organisation/urls.py
Normal file
12
organisation/urls.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 07.12.20
|
||||
|
||||
"""
|
||||
from django.urls import path
|
||||
|
||||
app_name = "organisation"
|
||||
urlpatterns = [
|
||||
]
|
3
organisation/views.py
Normal file
3
organisation/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in New Issue
Block a user