Skip to content

Commit

Permalink
Merge pull request #5342 from specify/issue-5334
Browse files Browse the repository at this point in the history
Hide tectonic tree for non paleo or geo disciplines
  • Loading branch information
CarolineDenis authored Oct 25, 2024
2 parents 7647b5d + 69034e8 commit 0b85e8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions specifyweb/specify/model_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,18 @@ class Meta:
abstract = True

PALEO_DISCIPLINES = {'paleobotany', 'invertpaleo', 'vertpaleo'}
GEOLOGY_DISCIPLINES = {'geology'}

class Discipline(models.Model):
def is_paleo(self):
return self.type.lower() in PALEO_DISCIPLINES

def is_geo(self):
return self.type.lower() in GEOLOGY_DISCIPLINES

def is_paleo_geo(self):
return self.is_paleo() or self.is_geo()

class Meta:
abstract = True

Expand Down
8 changes: 4 additions & 4 deletions specifyweb/specify/tree_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
GEO_TREES: Tuple[TREE_TABLE, ...] = ['Tectonicunit']

COMMON_TREES: Tuple[TREE_TABLE, ...] = ['Taxon', 'Storage',
'Geography', *GEO_TREES]
'Geography']

ALL_TRESS: Tuple[TREE_TABLE, ...] = [
*COMMON_TREES, 'Geologictimeperiod', 'Lithostrat']
*COMMON_TREES, 'Geologictimeperiod', 'Lithostrat', *GEO_TREES]


def tree_mutation(mutation):
Expand Down Expand Up @@ -456,10 +456,10 @@ def has_tree_read_permission(tree: TREE_TABLE) -> bool:
return has_table_permission(
request.specify_collection.id, request.specify_user.id, tree, 'read')

is_paleo_discipline = request.specify_collection.discipline.is_paleo()
is_paleo_or_geo_discipline = request.specify_collection.discipline.is_paleo_geo()

accessible_trees = tuple(filter(
has_tree_read_permission, ALL_TRESS if is_paleo_discipline else COMMON_TREES))
has_tree_read_permission, ALL_TRESS if is_paleo_or_geo_discipline else COMMON_TREES))

result = {}

Expand Down

0 comments on commit 0b85e8f

Please sign in to comment.