Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwenxuan authored and 杨国璇 committed Dec 25, 2024
1 parent 32dc50f commit 0d30a5e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
8 changes: 0 additions & 8 deletions seahub/repo_metadata/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,14 +1736,6 @@ def delete(self, request, repo_id):
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

# Remove _tags conditions from all table views
try:
RepoMetadataViews.objects.remove_tags_filter_conditions(repo_id)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

return Response({'success': True})


Expand Down
16 changes: 0 additions & 16 deletions seahub/repo_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,6 @@ def move_view(self, repo_id, source_view_id, source_folder_id, target_view_id, t
metadata_views.save()
return json.loads(metadata_views.details)

def remove_tags_filter_conditions(self, repo_id):
metadata_views = self.filter(repo_id=repo_id).first()
if not metadata_views:
return

view_details = json.loads(metadata_views.details)
views = view_details.get('views', [])

for view in views:
filters = view.get('filters', [])
new_filters = [f for f in filters if f.get('column_key') != '_tags']
view['filters'] = new_filters

metadata_views.details = json.dumps(view_details)
metadata_views.save()


class RepoMetadataViews(models.Model):
repo_id = models.CharField(max_length=36, db_index=True)
Expand Down

0 comments on commit 0d30a5e

Please sign in to comment.