Пример #1
0
def taxonomy_pre_save_handler(sender, instance, **kwargs):
    """Get iucn status before save."""
    if instance.rank == TaxonomicRank.CLASS.name:
        generate_permission(instance.scientific_name)

    if instance.is_species and not instance.iucn_status:
        iucn_status = get_iucn_status(species_name=instance.scientific_name)
        if iucn_status:
            instance.iucn_status = iucn_status
Пример #2
0
def taxon_pre_save_handler(sender, instance, **kwargs):
    """Get iucn status before save."""
    if instance.taxon_class:
        generate_permission(instance.taxon_class)

    if instance.common_name and not instance.iucn_status:
        iucn_status = get_iucn_status(species_name=instance.common_name)
        if iucn_status:
            instance.iucn_status = iucn_status
Пример #3
0
 def test_permission_already_exists(self):
     """
     Tests existed permission not generated
     """
     taxon_class = 'Aves'
     result = generate_permission(taxon_class)
     self.assertIsNone(result)
Пример #4
0
 def test_permission_generated(self):
     """
     Tests if permission generated if there is new taxon class
     """
     taxon_class = 'Animalia'
     result = generate_permission(taxon_class)
     self.assertIsNotNone(result)
Пример #5
0
 def handle(self, *args, **options):
     taxa = Taxon.objects.all().values('taxon_class').distinct()
     for taxon in taxa:
         generate_permission(taxon['taxon_class'])