Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

154 add challenge properties for header #155

Merged
merged 2 commits into from
Sep 8, 2021
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Create the configuration file and export its parameters to environment
variables.

cp .env.example .env
export $(grep -v '^#' .env | xargs -d '\n')
export $(grep -v '^#' .env | xargs)

Start the MongoDB instance.

Expand Down
4 changes: 4 additions & 0 deletions server/openapi_server/controllers/challenge_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def create_challenge(account_name): # noqa: E501
challenge_create_request = ChallengeCreateRequest.from_dict(connexion.request.get_json()) # noqa: E501
challenge = DbChallenge(
name=challenge_create_request.name,
displayName=challenge_create_request.display_name,
description=challenge_create_request.description,
status=challenge_create_request.status,
startDate=challenge_create_request.start_date,
endDate=challenge_create_request.end_date,
fullName="%s/%s" % (account_name, challenge_create_request.name),
ownerId=account_id
).save()
Expand Down
15 changes: 12 additions & 3 deletions server/openapi_server/dbmodels/challenge.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from bson import ObjectId
# import datetime
from mongoengine import Document, ReferenceField, StringField, ObjectIdField # noqa: E501
# DateTimeField, ListField, URLField,
from mongoengine import DateTimeField, Document, ReferenceField, StringField, ObjectIdField, URLField # noqa: E501
# , ListField

from openapi_server.dbmodels.account import Account
# from openapi_server.dbmodels.challenge_platform import ChallengePlatform
from openapi_server.dbmodels.challenge_platform import ChallengePlatform
# from openapi_server.dbmodels.grant import Grant
# from openapi_server.dbmodels.organization import Organization
# from openapi_server.dbmodels.person import Person
Expand All @@ -14,9 +14,18 @@
class Challenge(Document):
id = ObjectIdField(primary_key=True, default=ObjectId)
name = StringField(required=True)
displayName = StringField(min_length=3, max_length=60)
description = StringField(required=True)
fullName = StringField(required=True, unique=True)
ownerId = ReferenceField(Account)
websiteUrl = URLField()
status = StringField(
required=True,
choices=["active", "upcoming", "completed"] # TODO: DRY
)
startDate = DateTimeField()
endDate = DateTimeField()
platformId = ReferenceField(ChallengePlatform)

# summary = StringField()
# startDate = DateTimeField()
Expand Down