From 963213625aeb4e6aecf2fe9932a0bf9ea8b6caac Mon Sep 17 00:00:00 2001 From: Priya Thakur Date: Fri, 9 Feb 2024 14:04:07 +0800 Subject: [PATCH 1/3] remove unwanted models from boranga compponents --- .../components/conservation_status/models.py | 2 +- boranga/components/occurrence/models.py | 14 +- .../components/species_and_communities/api.py | 6 - .../species_and_communities/models.py | 133 ------------------ boranga/migrations/0191_auto_20240209_1323.py | 25 ++++ 5 files changed, 33 insertions(+), 147 deletions(-) create mode 100644 boranga/migrations/0191_auto_20240209_1323.py diff --git a/boranga/components/conservation_status/models.py b/boranga/components/conservation_status/models.py index adb15ac7..83b5d869 100644 --- a/boranga/components/conservation_status/models.py +++ b/boranga/components/conservation_status/models.py @@ -1733,4 +1733,4 @@ class ConservationStatusAmendmentRequestDocument(Document): def delete(self): if self.can_delete: - return super(ConservationStatusAmendmentRequestDocument, self).delete() \ No newline at end of file + return super(ConservationStatusAmendmentRequestDocument, self).delete() diff --git a/boranga/components/occurrence/models.py b/boranga/components/occurrence/models.py index 08d49a03..8156a552 100644 --- a/boranga/components/occurrence/models.py +++ b/boranga/components/occurrence/models.py @@ -606,7 +606,7 @@ class Meta: def __str__(self): return str(self.occurrence_report) # TODO: is the most appropriate? - +# Is used in HabitatComposition for multiple selection class LandForm(models.Model): """ # Admin List @@ -1011,13 +1011,13 @@ class Meta: def __str__(self): return str(self.occurrence_report) - +# used for Animal Observation(MultipleSelect) class PrimaryDetectionMethod(models.Model): """ # Admin List Used by: - - AnimalObservation + - AnimalObservation (MultipleSelect) """ name = models.CharField(max_length=250, blank=False, null=False, unique=True) @@ -1029,13 +1029,13 @@ class Meta: def __str__(self): return str(self.name) - +# used for Animal Observation(MultipleSelect) class ReproductiveMaturity(models.Model): """ # Admin List Used by: - - AnimalObservation + - AnimalObservation (MultipleSelect) """ name = models.CharField(max_length=250, blank=False, null=False, unique=True) @@ -1087,13 +1087,13 @@ class Meta: def __str__(self): return str(self.name) - +# sed for Animal Observation(MultipleSelect) class SecondarySign(models.Model): """ # Admin List Used by: - - AnimalObservation + - AnimalObservation (MultipleSelect) """ name = models.CharField(max_length=250, blank=False, null=False, unique=True) diff --git a/boranga/components/species_and_communities/api.py b/boranga/components/species_and_communities/api.py index f984c50f..039273da 100755 --- a/boranga/components/species_and_communities/api.py +++ b/boranga/components/species_and_communities/api.py @@ -60,15 +60,9 @@ District, SpeciesDistribution, CommunityDistribution, - # FloweringPeriod, - # FruitingPeriod, FloraRecruitmentType, - SeedViabilityGerminationInfo, RootMorphology, - PollinatorInformation, PostFireHabitatInteraction, - # BreedingPeriod, - FaunaBreeding, SpeciesConservationAttributes, CommunityConservationAttributes, DocumentCategory, diff --git a/boranga/components/species_and_communities/models.py b/boranga/components/species_and_communities/models.py index 8086a5ed..3b3ba7d5 100644 --- a/boranga/components/species_and_communities/models.py +++ b/boranga/components/species_and_communities/models.py @@ -899,24 +899,6 @@ def __str__(self): return str(self.id) # TODO: is the most appropriate? -# TODO Model not used anymore -class CommunityName(models.Model): - """ - # list derived from TEC - - Used by: - - Taxonomy - - """ - name = models.CharField(max_length=200, blank=False, unique=True) - - class Meta: - app_label = 'boranga' - - def __str__(self): - return str(self.name) - - class Community(models.Model): """ A collection of 2 or more Species within a specific location. @@ -1732,47 +1714,6 @@ def source(self): return self.community.id -# list used in Conservation Attributes -# class FloweringPeriod(models.Model): -# """ -# # list derived from WACensus - -# Used by: -# - SpeciesConservationAttributes - -# """ -# period = models.CharField(max_length=200, blank=False, unique=True) - -# class Meta: -# app_label = 'boranga' -# verbose_name = "Flowering Period" -# verbose_name_plural = "Flowering Periods" -# ordering = ['period'] - -# def __str__(self): -# return str(self.period) - - -# class FruitingPeriod(models.Model): -# """ -# # list derived from WACensus - -# Used by: -# - SpeciesConservationAttributes - -# """ -# period = models.CharField(max_length=200, blank=False, unique=True) - -# class Meta: -# app_label = 'boranga' -# verbose_name = "Fruiting Period" -# verbose_name_plural = "Fruiting Periods" -# ordering = ['period'] - -# def __str__(self): -# return str(self.period) - - class FloraRecruitmentType(models.Model): """ # list derived from WACensus @@ -1792,24 +1733,6 @@ class Meta: def __str__(self): return str(self.recruitment_type) -# TODO Not used -class SeedViabilityGerminationInfo(models.Model): - """ - # list derived from WACensus - - Used by: - - SpeciesConservationAttributes - - """ - name = models.CharField(max_length=200, blank=False, unique=True) - - class Meta: - app_label = 'boranga' - ordering = ['name'] - - def __str__(self): - return str(self.name) - class RootMorphology(models.Model): """ @@ -1830,24 +1753,6 @@ class Meta: def __str__(self): return str(self.name) -# TODO Not used -class PollinatorInformation(models.Model): - """ - # list derived from WACensus - - Used by: - - SpeciesConservationAttributes - - """ - name = models.CharField(max_length=200, blank=False, unique=True) - - class Meta: - app_label = 'boranga' - ordering = ['name'] - - def __str__(self): - return str(self.name) - class PostFireHabitatInteraction(models.Model): """ @@ -1869,44 +1774,6 @@ def __str__(self): return str(self.name) -# class BreedingPeriod(models.Model): -# """ -# # list derived from WACensus - -# Used by: -# - SpeciesConservationAttributes - -# """ -# period = models.CharField(max_length=200, blank=False, unique=True) - -# class Meta: -# app_label = 'boranga' -# verbose_name = "Breeding Period" -# verbose_name_plural = "Breeding Periods" -# ordering = ['period'] - -# def __str__(self): -# return str(self.period) - -# TODO Not USed -class FaunaBreeding(models.Model): - """ - # list derived from WACensus - - Used by: - - SpeciesConservationAttributes - - """ - breeding_type = models.CharField(max_length=200, blank=False, unique=True) - - class Meta: - app_label = 'boranga' - ordering = ['breeding_type'] - - def __str__(self): - return str(self.breeding_type) - - class SpeciesConservationAttributes(models.Model): """ Species conservation attributes data. diff --git a/boranga/migrations/0191_auto_20240209_1323.py b/boranga/migrations/0191_auto_20240209_1323.py new file mode 100644 index 00000000..1c3d9bfa --- /dev/null +++ b/boranga/migrations/0191_auto_20240209_1323.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.23 on 2024-02-09 05:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0190_ocrconservationthreat'), + ] + + operations = [ + migrations.DeleteModel( + name='CommunityName', + ), + migrations.DeleteModel( + name='FaunaBreeding', + ), + migrations.DeleteModel( + name='PollinatorInformation', + ), + migrations.DeleteModel( + name='SeedViabilityGerminationInfo', + ), + ] From 703cfa818b08dfece5f47efc7ac0cd2ee1c51bda Mon Sep 17 00:00:00 2001 From: Priya Thakur Date: Mon, 12 Feb 2024 11:21:30 +0800 Subject: [PATCH 2/3] remove some unwanted models --- boranga/components/main/api.py | 13 +++++++----- boranga/components/main/models.py | 14 ++++++------- boranga/components/main/serializers.py | 13 +++++++----- boranga/components/proposals/admin.py | 6 +++--- boranga/components/proposals/api.py | 2 +- boranga/components/proposals/models.py | 5 +++-- boranga/migrations/0192_auto_20240212_1118.py | 20 +++++++++++++++++++ boranga/urls.py | 2 +- 8 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 boranga/migrations/0192_auto_20240212_1118.py diff --git a/boranga/components/main/api.py b/boranga/components/main/api.py index 70b52dc6..01c3ab85 100755 --- a/boranga/components/main/api.py +++ b/boranga/components/main/api.py @@ -13,11 +13,14 @@ from django.urls import reverse from boranga.components.main.models import ( ApplicationType, - RequiredDocument, Question, GlobalSettings + # RequiredDocument, + Question, + GlobalSettings ) from boranga.components.main.serializers import ( ApplicationTypeSerializer, - RequiredDocumentSerializer, QuestionSerializer, GlobalSettingsSerializer, OracleSerializer, BookingSettlementReportSerializer, + # RequiredDocumentSerializer, + QuestionSerializer, GlobalSettingsSerializer, OracleSerializer, BookingSettlementReportSerializer, ) from django.core.exceptions import ValidationError from django.db.models import Q @@ -37,9 +40,9 @@ class GlobalSettingsViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = GlobalSettingsSerializer -class RequiredDocumentViewSet(viewsets.ReadOnlyModelViewSet): - queryset = RequiredDocument.objects.all() - serializer_class = RequiredDocumentSerializer +# class RequiredDocumentViewSet(viewsets.ReadOnlyModelViewSet): +# queryset = RequiredDocument.objects.all() +# serializer_class = RequiredDocumentSerializer # def get_queryset(self): # categories=ActivityCategory.objects.filter(activity_type='marine') diff --git a/boranga/components/main/models.py b/boranga/components/main/models.py index e53b21ee..3e252483 100644 --- a/boranga/components/main/models.py +++ b/boranga/components/main/models.py @@ -84,15 +84,15 @@ class Meta: abstract = True -#@python_2_unicode_compatible -class RequiredDocument(models.Model): - question = models.TextField(blank=False) +# #@python_2_unicode_compatible +# class RequiredDocument(models.Model): +# question = models.TextField(blank=False) - class Meta: - app_label = 'boranga' +# class Meta: +# app_label = 'boranga' - def __str__(self): - return self.question +# def __str__(self): +# return self.question #@python_2_unicode_compatible class ApplicationType(models.Model): diff --git a/boranga/components/main/serializers.py b/boranga/components/main/serializers.py index 6df4a765..556c6a81 100755 --- a/boranga/components/main/serializers.py +++ b/boranga/components/main/serializers.py @@ -2,7 +2,10 @@ from django.db.models import Sum, Max from boranga.components.main.models import ( CommunicationsLogEntry, - RequiredDocument, Question, GlobalSettings, ApplicationType, + # RequiredDocument, + Question, + GlobalSettings, + ApplicationType, ) from ledger_api_client.ledger_models import EmailUserRO as EmailUser, EmailUserRO from datetime import datetime, date @@ -52,10 +55,10 @@ class Meta: -class RequiredDocumentSerializer(serializers.ModelSerializer): - class Meta: - model = RequiredDocument - fields = ('id', 'park','activity', 'question') +# class RequiredDocumentSerializer(serializers.ModelSerializer): +# class Meta: +# model = RequiredDocument +# fields = ('id', 'park','activity', 'question') class QuestionSerializer(serializers.ModelSerializer): diff --git a/boranga/components/proposals/admin.py b/boranga/components/proposals/admin.py index af049c9f..059cfeaf 100755 --- a/boranga/components/proposals/admin.py +++ b/boranga/components/proposals/admin.py @@ -6,7 +6,7 @@ SystemMaintenance, ApplicationType, OracleCode, - RequiredDocument, + # RequiredDocument, Question, GlobalSettings, ) @@ -142,8 +142,8 @@ class OracleCodeInline(admin.TabularInline): can_delete = False # @admin.register(RequiredDocument) -class RequiredDocumentAdmin(admin.ModelAdmin): - pass +# class RequiredDocumentAdmin(admin.ModelAdmin): +# pass # @admin.register(GlobalSettings) class GlobalSettingsAdmin(admin.ModelAdmin): diff --git a/boranga/components/proposals/api.py b/boranga/components/proposals/api.py index 3493b4a3..fa5159f8 100755 --- a/boranga/components/proposals/api.py +++ b/boranga/components/proposals/api.py @@ -35,7 +35,7 @@ from django.urls import reverse from django.shortcuts import render, redirect, get_object_or_404 -from boranga.components.main.models import Document, ApplicationType, RequiredDocument +from boranga.components.main.models import Document, ApplicationType from boranga.components.proposals.models import ( ProposalType, Proposal, diff --git a/boranga/components/proposals/models.py b/boranga/components/proposals/models.py index 2fc7359b..1a20be6f 100644 --- a/boranga/components/proposals/models.py +++ b/boranga/components/proposals/models.py @@ -27,7 +27,8 @@ #Organisation as ledger_organisation, OrganisationAddress, CommunicationsLogEntry, UserAction, Document, ApplicationType, - RequiredDocument, RevisionedMixin + # RequiredDocument, + RevisionedMixin ) from boranga.components.main.utils import get_department_user from boranga.components.proposals.email import ( @@ -255,7 +256,7 @@ class ProposalRequiredDocument(Document): _file = models.FileField(upload_to=update_proposal_required_doc_filename, max_length=512, storage=private_storage) input_name = models.CharField(max_length=255,null=True,blank=True) can_delete = models.BooleanField(default=True) # after initial submit prevent document from being deleted - required_doc = models.ForeignKey('RequiredDocument',related_name='proposals', on_delete=models.CASCADE) + # required_doc = models.ForeignKey('RequiredDocument',related_name='proposals', on_delete=models.CASCADE) can_hide= models.BooleanField(default=False) # after initial submit, document cannot be deleted but can be hidden hidden=models.BooleanField(default=False) # after initial submit prevent document from being deleted diff --git a/boranga/migrations/0192_auto_20240212_1118.py b/boranga/migrations/0192_auto_20240212_1118.py new file mode 100644 index 00000000..76d3fbea --- /dev/null +++ b/boranga/migrations/0192_auto_20240212_1118.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.23 on 2024-02-12 03:18 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0191_auto_20240209_1323'), + ] + + operations = [ + migrations.RemoveField( + model_name='proposalrequireddocument', + name='required_doc', + ), + migrations.DeleteModel( + name='RequiredDocument', + ), + ] diff --git a/boranga/urls.py b/boranga/urls.py index 5f327e59..67586f58 100755 --- a/boranga/urls.py +++ b/boranga/urls.py @@ -87,7 +87,7 @@ router.register(r'global_settings', main_api.GlobalSettingsViewSet) #router.register(r'application_types', main_api.ApplicationTypeViewSet) router.register(r'assessments', proposal_api.ProposalAssessmentViewSet) -router.register(r'required_documents', main_api.RequiredDocumentViewSet) +# router.register(r'required_documents', main_api.RequiredDocumentViewSet) router.register(r'questions', main_api.QuestionViewSet) api_patterns = [ From 2d03af0ee1c4867573b5536290fc64536549d83a Mon Sep 17 00:00:00 2001 From: Priya Thakur Date: Mon, 12 Feb 2024 11:25:36 +0800 Subject: [PATCH 3/3] update cron file --- cron | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cron b/cron index d6563224..55b2baae 100644 --- a/cron +++ b/cron @@ -1,2 +1 @@ -0 1 * * * root eval $(grep -v '^#' /etc/.cronenv | xargs -d "\n" -I {} echo export \"{}\" ) && python3 /app/manage.py runcrons >> /app/logs/cronjob.log 2>&1 - +*/5 * * * * root eval $(grep -v '^#' /etc/.cronenv | xargs -d "\n" -I {} echo export \"{}\" ) && python3 /app/manage.py runcrons >> /app/logs/cronjob.log 2>&1 \ No newline at end of file