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

Hide tectonic tree for non paleo or geo disciplines #5342

Merged
merged 1 commit into from
Oct 25, 2024
Merged
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
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
Loading