Skip to content

Commit

Permalink
Change show_karton to false and don't include "karton" key in task pa…
Browse files Browse the repository at this point in the history
…yload (#794)
  • Loading branch information
Repumba committed Apr 25, 2023
1 parent 22e9ce1 commit 751898c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 5 additions & 1 deletion mwdb/model/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,11 @@ def remove_tag(self, tag_name, commit=True):
return is_removed

def get_attributes(
self, as_dict=False, check_permissions=True, show_hidden=False, show_karton=True
self,
as_dict=False,
check_permissions=True,
show_hidden=False,
show_karton=False,
):
"""
Gets all object attributes
Expand Down
6 changes: 2 additions & 4 deletions mwdb/resources/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def get(self, type, identifier):
if db_object is None:
raise NotFound("Object not found")

attributes = db_object.get_attributes(
show_hidden=show_hidden, show_karton=False
)
attributes = db_object.get_attributes(show_hidden=show_hidden)
schema = AttributeListResponseSchema()
return schema.dump({"attributes": attributes})

Expand Down Expand Up @@ -167,7 +165,7 @@ def post(self, type, identifier):

db.session.commit()
db.session.refresh(db_object)
attributes = db_object.get_attributes(show_karton=False)
attributes = db_object.get_attributes()
attribute = next((attr for attr in attributes if attr.key == key), None)
if is_new:
hooks.on_created_attribute(db_object, attribute)
Expand Down
4 changes: 2 additions & 2 deletions mwdb/resources/metakey.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get(self, type, identifier):
if db_object is None:
raise NotFound("Object not found")

metakeys = db_object.get_attributes(show_hidden=show_hidden)
metakeys = db_object.get_attributes(show_hidden=show_hidden, show_karton=True)
schema = MetakeyListResponseSchema()
return schema.dump({"metakeys": metakeys})

Expand Down Expand Up @@ -179,7 +179,7 @@ def post(self, type, identifier):

db.session.commit()
db.session.refresh(db_object)
metakeys = db_object.get_attributes()
metakeys = db_object.get_attributes(show_karton=True)
schema = MetakeyListResponseSchema()
return schema.dump({"metakeys": metakeys})

Expand Down
2 changes: 1 addition & 1 deletion mwdb/schema/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_accessible_attributes(self, data, object, **kwargs):
"""
Replace all object attributes with attributes accessible for current user
"""
object_attributes = object.get_attributes(show_karton=False)
object_attributes = object.get_attributes()
schema = AttributeItemResponseSchema()
attributes_serialized = schema.dump(object_attributes, many=True)
return {**data, "attributes": attributes_serialized}
Expand Down

0 comments on commit 751898c

Please sign in to comment.