#17 Update setup
* removes unused organisation app from project * removes null=True parameters for M2M fields in models
This commit is contained in:
		
							parent
							
								
									52516a295d
								
							
						
					
					
						commit
						f4bfc0db6e
					
				@ -76,7 +76,6 @@ class KonovaCodeList(models.Model):
 | 
			
		||||
    )
 | 
			
		||||
    codes = models.ManyToManyField(
 | 
			
		||||
        KonovaCode,
 | 
			
		||||
        null=True,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        help_text="Codes for this list",
 | 
			
		||||
        related_name="code_lists"
 | 
			
		||||
 | 
			
		||||
@ -141,7 +141,6 @@ class AbstractCompensation(BaseObject):
 | 
			
		||||
 | 
			
		||||
    fundings = models.ManyToManyField(
 | 
			
		||||
        KonovaCode,
 | 
			
		||||
        null=True,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        limit_choices_to={
 | 
			
		||||
            "code_lists__in": [CODELIST_COMPENSATION_FUNDING_ID],
 | 
			
		||||
 | 
			
		||||
@ -161,7 +161,6 @@ class LegalData(UuidModel):
 | 
			
		||||
    )
 | 
			
		||||
    laws = models.ManyToManyField(
 | 
			
		||||
        KonovaCode,
 | 
			
		||||
        null=True,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        limit_choices_to={
 | 
			
		||||
            "code_lists__in": [CODELIST_LAW_ID],
 | 
			
		||||
 | 
			
		||||
@ -14,35 +14,6 @@ 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):
 | 
			
		||||
 | 
			
		||||
@ -11,8 +11,7 @@ from django.contrib.auth.models import User, Group
 | 
			
		||||
from django.core.management import BaseCommand
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
 | 
			
		||||
from konova.management.commands.setup_data import TEST_ORGANISATION_DATA, GROUPS_DATA, USER_NOTIFICATIONS_NAMES
 | 
			
		||||
from organisation.models import Organisation
 | 
			
		||||
from konova.management.commands.setup_data import GROUPS_DATA, USER_NOTIFICATIONS_NAMES
 | 
			
		||||
from user.enums import UserNotificationEnum
 | 
			
		||||
from user.models import UserNotification
 | 
			
		||||
 | 
			
		||||
@ -26,7 +25,6 @@ class Command(BaseCommand):
 | 
			
		||||
        try:
 | 
			
		||||
            with transaction.atomic():
 | 
			
		||||
                self._init_superuser()
 | 
			
		||||
                self._init_test_organisation()
 | 
			
		||||
                self._init_default_groups()
 | 
			
		||||
                self._init_user_notifications()
 | 
			
		||||
        except KeyboardInterrupt:
 | 
			
		||||
@ -62,20 +60,6 @@ class Command(BaseCommand):
 | 
			
		||||
        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
 | 
			
		||||
@ -112,6 +96,9 @@ class Command(BaseCommand):
 | 
			
		||||
 | 
			
		||||
        self._break_line()
 | 
			
		||||
 | 
			
		||||
    def _init_codelists(self):
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    def _break_line(self):
 | 
			
		||||
        """ Simply prints a line break
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -65,7 +65,6 @@ 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 OrganisationAutocomplete, NonOfficialOrganisationAutocomplete, EcoAccountAutocomplete, \
 | 
			
		||||
from konova.autocompletes import EcoAccountAutocomplete, \
 | 
			
		||||
    InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete, LawCodeAutocomplete, \
 | 
			
		||||
    RegistrationOfficeCodeAutocomplete, ConservationOfficeCodeAutocomplete, ProcessTypeCodeAutocomplete, \
 | 
			
		||||
    CompensationFundingCodeAutocomplete
 | 
			
		||||
@ -34,7 +34,6 @@ 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")),
 | 
			
		||||
@ -43,8 +42,6 @@ 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"),
 | 
			
		||||
 | 
			
		||||
@ -1,13 +0,0 @@
 | 
			
		||||
from django.contrib import admin
 | 
			
		||||
 | 
			
		||||
from organisation.models import Organisation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class OrganisationAdmin(admin.ModelAdmin):
 | 
			
		||||
    list_display = [
 | 
			
		||||
        "name",
 | 
			
		||||
        "created",
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
admin.site.register(Organisation, OrganisationAdmin)
 | 
			
		||||
@ -1,5 +0,0 @@
 | 
			
		||||
from django.apps import AppConfig
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class OrganisationConfig(AppConfig):
 | 
			
		||||
    name = 'organisation'
 | 
			
		||||
@ -1,8 +0,0 @@
 | 
			
		||||
"""
 | 
			
		||||
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
 | 
			
		||||
@ -1,16 +0,0 @@
 | 
			
		||||
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
 | 
			
		||||
@ -1,8 +0,0 @@
 | 
			
		||||
"""
 | 
			
		||||
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 _
 | 
			
		||||
@ -1,3 +0,0 @@
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
# Create your tests here.
 | 
			
		||||
@ -1,12 +0,0 @@
 | 
			
		||||
"""
 | 
			
		||||
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 = [
 | 
			
		||||
]
 | 
			
		||||
@ -1,3 +0,0 @@
 | 
			
		||||
from django.shortcuts import render
 | 
			
		||||
 | 
			
		||||
# Create your views here.
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user