Skip to content

Commit

Permalink
dataset images, json validation, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
biodiv committed Feb 17, 2023
1 parent dd18ad2 commit c6d5eae
Show file tree
Hide file tree
Showing 20 changed files with 1,499 additions and 599 deletions.
45 changes: 0 additions & 45 deletions localcosmos_server/api/serializer_fields.py

This file was deleted.

2 changes: 1 addition & 1 deletion localcosmos_server/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LocalcosmosUserSerializer(serializers.ModelSerializer):

class Meta:
model = User
fields = ('id', 'uuid', 'username', 'first_name', 'last_name', 'email')
fields = ('uuid', 'username', 'first_name', 'last_name', 'email')


class RegistrationSerializer(serializers.ModelSerializer):
Expand Down
23 changes: 23 additions & 0 deletions localcosmos_server/datasets/api/examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os, json, localcosmos_server
from localcosmos_server.tests.common import DataCreator
lc_path = os.path.dirname(localcosmos_server.__file__)

observation_form_json_path = os.path.join(lc_path, 'tests/data_for_tests/observation_form.json')

def get_observation_form_example():

with open(observation_form_json_path, 'rb') as observation_form_file:
observation_form = json.loads(observation_form_file.read())

return observation_form


def get_dataset_data_example():

observation_form_json = get_observation_form_example()

data_creator = DataCreator()

data = data_creator(observation_form_json=observation_form_json)
return data

4 changes: 2 additions & 2 deletions localcosmos_server/datasets/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def has_permission(self, request, view):
app_state = 'review'

app_settings = app.get_settings(app_state=app_state)

allow_anonymous_observations = app_settings['OPTIONS'].get('allowAnonymousObservations', False)

allow_anonymous_observations = app_settings['OPTIONS'].get('allowAnonymousObservations', False)

if allow_anonymous_observations == False and request.user.is_authenticated == False:
return False

Expand Down

0 comments on commit c6d5eae

Please sign in to comment.