Skip to content

Commit

Permalink
feat: add dataset list to Project serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Oct 4, 2024
1 parent 38d2cc9 commit 028bf3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
13 changes: 7 additions & 6 deletions uvdat/core/rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class Meta:
fields = ['id', 'username', 'email', 'first_name', 'last_name', 'is_superuser']


class DatasetSerializer(serializers.ModelSerializer):
class Meta:
model = Dataset
fields = '__all__'


class ProjectPermissionsSerializer(serializers.Serializer):
owner_id = serializers.IntegerField()
collaborator_ids = serializers.ListField(child=serializers.IntegerField())
Expand All @@ -40,6 +46,7 @@ class ProjectSerializer(serializers.ModelSerializer):
collaborators = serializers.SerializerMethodField('get_collaborators')
followers = serializers.SerializerMethodField('get_followers')
item_counts = serializers.SerializerMethodField('get_item_counts')
datasets = DatasetSerializer(many=True)

def get_center(self, obj):
# Web client expects Lon, Lat
Expand Down Expand Up @@ -81,12 +88,6 @@ class Meta:
fields = '__all__'


class DatasetSerializer(serializers.ModelSerializer):
class Meta:
model = Dataset
fields = '__all__'


class FileItemSerializer(serializers.ModelSerializer):
class Meta:
model = FileItem
Expand Down
11 changes: 3 additions & 8 deletions web/src/components/ProjectConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import DatasetList from "./DatasetList.vue";
import AccessControl from "./AccessControl.vue";
import {
getDatasets,
getProjectDatasets,
createProject,
deleteProject,
patchProject,
Expand Down Expand Up @@ -111,12 +110,10 @@ export default {
function selectProject(v: Record<string, unknown>) {
if (selectedProject.value?.id != v.id) {
getProjectDatasets(v.id as number).then((data) => {
projDatasets.value = data;
});
selectedProject.value = availableProjects.value.find(
(p) => p.id == v.id
);
projDatasets.value = selectedProject.value?.datasets;
}
}
Expand Down Expand Up @@ -191,10 +188,8 @@ export default {
patchProject(selectedProject.value.id, {
datasets: ids,
}).then((project) => {
getProjectDatasets(project.id).then((datasets) => {
projDatasets.value = datasets;
saving.value = false;
});
projDatasets.value = project.datasets;
saving.value = false;
});
}
}
Expand Down

0 comments on commit 028bf3a

Please sign in to comment.