Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ap working #177

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 10 additions & 2 deletions boranga/components/species_and_communities/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
class DocumentSubCategoryAdmin(admin.ModelAdmin):
list_display = ['document_sub_category_name', 'document_category']

@admin.register(FloweringPeriod)
class FloweringPeriodAdmin(admin.ModelAdmin):
list_display = ['period']

@admin.register(FruitingPeriod)
class FruitingPeriodAdmin(admin.ModelAdmin):
list_display = ['period']

# Each of the following models will be available to Django Admin.
admin.site.register(GroupType)
admin.site.register(Region)
Expand All @@ -59,8 +67,8 @@ class DocumentSubCategoryAdmin(admin.ModelAdmin):
# admin.site.register(PhylogeneticGroup)
# admin.site.register(Genus)
admin.site.register(Kingdom)
admin.site.register(FloweringPeriod)
admin.site.register(FruitingPeriod)
# admin.site.register(FloweringPeriod)
# admin.site.register(FruitingPeriod)
admin.site.register(FloraRecruitmentType)
# admin.site.register(SeedViabilityGerminationInfo)
admin.site.register(RootMorphology)
Expand Down
53 changes: 34 additions & 19 deletions boranga/components/species_and_communities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,22 @@ class FloweringPeriod(models.Model):
- SpeciesConservationAttributes

"""
period = models.CharField(max_length=200, blank=False, unique=True)
PERIOD_CHOICES = (
('January', 'January'),
('February', 'February'),
('March', 'March'),
('April', 'April'),
('May', 'May'),
('June', 'June'),
('July', 'July'),
('August', 'August'),
('September', 'September'),
('October', 'October'),
('November', 'November'),
('December', 'December'),
)

period = models.CharField(max_length=200, blank=False, unique=True, choices=PERIOD_CHOICES)

class Meta:
app_label = 'boranga'
Expand All @@ -1938,7 +1953,8 @@ class FruitingPeriod(models.Model):
- SpeciesConservationAttributes

"""
period = models.CharField(max_length=200, blank=False, unique=True)

period = models.CharField(max_length=200, blank=False, unique=True, choices=FloweringPeriod.PERIOD_CHOICES)

class Meta:
app_label = 'boranga'
Expand Down Expand Up @@ -2054,7 +2070,7 @@ class BreedingPeriod(models.Model):
- SpeciesConservationAttributes

"""
period = models.CharField(max_length=200, blank=False, unique=True)
period = models.CharField(max_length=200, blank=False, unique=True, choices=FloweringPeriod.PERIOD_CHOICES)

class Meta:
app_label = 'boranga'
Expand Down Expand Up @@ -2093,26 +2109,25 @@ class SpeciesConservationAttributes(models.Model):
Is:
- Table
"""
PERIOD_CHOICES = (('january', 'January'),
('february', 'February'),
('march', 'March'),
('april', 'April'),
('may', 'May'),
('june', 'June'),
('july', 'July'),
('august', 'August'),
('september', 'September'),
('october', 'October'),
('november', 'November'),
('december', 'December'),
PERIOD_CHOICES = ((1, 'January'),
(2, 'February'),
(3, 'March'),
(4, 'April'),
(5, 'May'),
(6, 'June'),
(7, 'July'),
(8, 'August'),
(9, 'September'),
(10, 'October'),
(11, 'November'),
(12, 'December'),
)

species = models.ForeignKey(Species, on_delete=models.CASCADE, unique=True, null=True, related_name="species_conservation_attributes")

# flora related attributes
flowering_period = models.ForeignKey(FloweringPeriod, on_delete=models.SET_NULL, null=True, blank=True)
flowering_prd = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True)
fruiting_period = models.ForeignKey(FruitingPeriod, on_delete=models.SET_NULL, null=True, blank=True)
flowering_period = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True)
fruiting_period = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True)
flora_recruitment_type = models.ForeignKey(FloraRecruitmentType, on_delete=models.SET_NULL, null=True, blank=True)
flora_recruitment_notes = models.CharField(max_length=1000,null=True, blank=True)
seed_viability_germination_info = models.CharField(max_length=1000,null=True, blank=True)
Expand All @@ -2121,7 +2136,7 @@ class SpeciesConservationAttributes(models.Model):
response_to_dieback = models.CharField(max_length=1500, null=True, blank=True)

# fauna related attributes
breeding_period = models.ForeignKey(BreedingPeriod, on_delete=models.SET_NULL, null=True, blank=True)
breeding_period = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True)
fauna_breeding = models.CharField(max_length=2000,null=True, blank=True)
fauna_reproductive_capacity = models.CharField(max_length=200,null=True, blank=True)
diet_and_food_source = models.CharField(max_length=500, null=True, blank=True)
Expand Down
23 changes: 10 additions & 13 deletions boranga/components/species_and_communities/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ class Meta:
'id',
'species_id',
#flora related attributes
'flowering_period_id',
'flowering_prd',
'fruiting_period_id',
'flowering_period',
'fruiting_period',
'flora_recruitment_type_id',
'flora_recruitment_notes',
'seed_viability_germination_info',
Expand All @@ -353,7 +352,7 @@ class Meta:
'hydrology',
'response_to_dieback',
# fauna related attributes
'breeding_period_id',
'breeding_period',
'fauna_breeding',
'fauna_reproductive_capacity',
'diet_and_food_source',
Expand All @@ -377,27 +376,25 @@ def __init__(self, *args, **kwargs):
PERIOD_CHOICES = []
for rs in SpeciesConservationAttributes.PERIOD_CHOICES:
PERIOD_CHOICES.append(([rs[0], rs[1]]))
self.fields['flowering_prd'] = serializers.MultipleChoiceField(choices=PERIOD_CHOICES, allow_blank=False)
self.fields['flowering_period', 'fruiting_period', 'breeding_period'] = serializers.MultipleChoiceField(choices=PERIOD_CHOICES, allow_blank=False)


class SaveSpeciesConservationAttributesSerializer(serializers.ModelSerializer):
species_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
flowering_period_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
flowering_prd = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False)
fruiting_period_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
flowering_period = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False)
fruiting_period = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False)
flora_recruitment_type_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
root_morphology_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
breeding_period_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
breeding_period = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False)
post_fire_habitat_interaction_id = serializers.IntegerField(required=False, allow_null=True, write_only= True)
class Meta:
model = SpeciesConservationAttributes
fields = (
'id',
'species_id',
#flora related attributes
'flowering_period_id',
'flowering_prd',
'fruiting_period_id',
'flowering_period',
'fruiting_period',
'flora_recruitment_type_id',
'flora_recruitment_notes',
'seed_viability_germination_info',
Expand All @@ -406,7 +403,7 @@ class Meta:
'hydrology',
'response_to_dieback',
# fauna related attributes
'breeding_period_id',
'breeding_period',
'fauna_breeding',
'fauna_reproductive_capacity',
'diet_and_food_source',
Expand Down
Loading