This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Run openapi-generator to add challenge sponsor stub * Add code for challenge sponsors * Sorchallenge controller functions in alphabetic order * Rename CloudProvider to ComputeProvider * Rename CloudProvider to ComputeProvider * Revert "Rename CloudProvider to ComputeProvider" This reverts commit 0d1a695. * Rename DB model parameter value to ComputeProvider
- Loading branch information
1 parent
2ac0529
commit cc6696b
Showing
13 changed files
with
986 additions
and
1,000 deletions.
There are no files selected for viewing
543 changes: 290 additions & 253 deletions
543
server/openapi_server/controllers/challenge_controller.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import datetime | ||
from bson import ObjectId | ||
from mongoengine import DateTimeField, Document, ObjectIdField, StringField, ListField, ReferenceField, IntField # noqa: E501 | ||
|
||
from openapi_server.dbmodels.challenge import Challenge | ||
|
||
|
||
class ChallengeSponsor(Document): | ||
id = ObjectIdField(primary_key=True, default=ObjectId) | ||
name = StringField(required=True) | ||
login = StringField() | ||
roles = ListField(StringField(choices=["ChallengeOrganizer", "ComputeProvider", "DataProvider", "Funder", "Other"]), default=[]) # noqa: E501 | ||
challengeId = ReferenceField(Challenge, required=True) | ||
createdAt = DateTimeField(required=True, default=datetime.datetime.now) | ||
updatedAt = DateTimeField(required=True, default=datetime.datetime.now) | ||
v = IntField(db_field='__v') | ||
|
||
def to_dict(self): | ||
doc = self.to_mongo().to_dict() | ||
doc['id'] = str(self.pk) | ||
doc.pop('challengeId', None) | ||
return doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
# coding: utf-8 | ||
|
||
from __future__ import absolute_import | ||
from datetime import date, datetime # noqa: F401 | ||
|
||
from typing import List, Dict # noqa: F401 | ||
|
||
from openapi_server.models.base_model_ import Model | ||
from openapi_server.models.challenge_sponsor_create_request import ChallengeSponsorCreateRequest | ||
from openapi_server.models.challenge_sponsor_create_response import ChallengeSponsorCreateResponse | ||
from openapi_server.models.challenge_sponsor_role import ChallengeSponsorRole | ||
import re | ||
from openapi_server import util | ||
|
||
from openapi_server.models.challenge_sponsor_create_request import ChallengeSponsorCreateRequest # noqa: E501 | ||
from openapi_server.models.challenge_sponsor_create_response import ChallengeSponsorCreateResponse # noqa: E501 | ||
from openapi_server.models.challenge_sponsor_role import ChallengeSponsorRole # noqa: E501 | ||
import re # noqa: E501 | ||
|
||
class ChallengeSponsor(Model): | ||
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
Do not edit the class manually. | ||
""" | ||
|
||
def __init__(self, id=None, name=None, login=None, roles=None): # noqa: E501 | ||
"""ChallengeSponsor - a model defined in OpenAPI | ||
:param id: The id of this ChallengeSponsor. # noqa: E501 | ||
:type id: str | ||
:param name: The name of this ChallengeSponsor. # noqa: E501 | ||
:type name: str | ||
:param login: The login of this ChallengeSponsor. # noqa: E501 | ||
:type login: str | ||
:param roles: The roles of this ChallengeSponsor. # noqa: E501 | ||
:type roles: List[ChallengeSponsorRole] | ||
""" | ||
self.openapi_types = { | ||
'id': str, | ||
'name': str, | ||
'login': str, | ||
'roles': List[ChallengeSponsorRole] | ||
} | ||
|
||
self.attribute_map = { | ||
'id': 'id', | ||
'name': 'name', | ||
'login': 'login', | ||
'roles': 'roles' | ||
} | ||
|
||
self._id = id | ||
self._name = name | ||
self._login = login | ||
self._roles = roles | ||
|
||
@classmethod | ||
def from_dict(cls, dikt) -> 'ChallengeSponsor': | ||
"""Returns the dict as a model | ||
:param dikt: A dict. | ||
:type: dict | ||
:return: The ChallengeSponsor of this ChallengeSponsor. # noqa: E501 | ||
:rtype: ChallengeSponsor | ||
""" | ||
return util.deserialize_model(dikt, cls) | ||
|
||
@property | ||
def id(self): | ||
"""Gets the id of this ChallengeSponsor. | ||
The unique identifier of a challenge sponsor # noqa: E501 | ||
:return: The id of this ChallengeSponsor. | ||
:rtype: str | ||
""" | ||
return self._id | ||
|
||
@id.setter | ||
def id(self, id): | ||
"""Sets the id of this ChallengeSponsor. | ||
The unique identifier of a challenge sponsor # noqa: E501 | ||
:param id: The id of this ChallengeSponsor. | ||
:type id: str | ||
""" | ||
if id is None: | ||
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 | ||
|
||
self._id = id | ||
|
||
@property | ||
def name(self): | ||
"""Gets the name of this ChallengeSponsor. | ||
:return: The name of this ChallengeSponsor. | ||
:rtype: str | ||
""" | ||
return self._name | ||
|
||
@name.setter | ||
def name(self, name): | ||
"""Sets the name of this ChallengeSponsor. | ||
:param name: The name of this ChallengeSponsor. | ||
:type name: str | ||
""" | ||
if name is None: | ||
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 | ||
|
||
self._name = name | ||
|
||
@property | ||
def login(self): | ||
"""Gets the login of this ChallengeSponsor. | ||
The user or organization account name # noqa: E501 | ||
:return: The login of this ChallengeSponsor. | ||
:rtype: str | ||
""" | ||
return self._login | ||
|
||
@login.setter | ||
def login(self, login): | ||
"""Sets the login of this ChallengeSponsor. | ||
The user or organization account name # noqa: E501 | ||
:param login: The login of this ChallengeSponsor. | ||
:type login: str | ||
""" | ||
if login is not None and len(login) > 25: | ||
raise ValueError("Invalid value for `login`, length must be less than or equal to `25`") # noqa: E501 | ||
if login is not None and len(login) < 3: | ||
raise ValueError("Invalid value for `login`, length must be greater than or equal to `3`") # noqa: E501 | ||
if login is not None and not re.search(r'^[a-z0-9]+(?:-[a-z0-9]+)*$', login): # noqa: E501 | ||
raise ValueError("Invalid value for `login`, must be a follow pattern or equal to `/^[a-z0-9]+(?:-[a-z0-9]+)*$/`") # noqa: E501 | ||
|
||
self._login = login | ||
|
||
@property | ||
def roles(self): | ||
"""Gets the roles of this ChallengeSponsor. | ||
:return: The roles of this ChallengeSponsor. | ||
:rtype: List[ChallengeSponsorRole] | ||
""" | ||
return self._roles | ||
|
||
@roles.setter | ||
def roles(self, roles): | ||
"""Sets the roles of this ChallengeSponsor. | ||
:param roles: The roles of this ChallengeSponsor. | ||
:type roles: List[ChallengeSponsorRole] | ||
""" | ||
|
||
self._roles = roles |
130 changes: 130 additions & 0 deletions
130
server/openapi_server/models/challenge_sponsor_create_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# coding: utf-8 | ||
|
||
from __future__ import absolute_import | ||
from datetime import date, datetime # noqa: F401 | ||
|
||
from typing import List, Dict # noqa: F401 | ||
|
||
from openapi_server.models.base_model_ import Model | ||
from openapi_server.models.challenge_sponsor_role import ChallengeSponsorRole | ||
import re | ||
from openapi_server import util | ||
|
||
from openapi_server.models.challenge_sponsor_role import ChallengeSponsorRole # noqa: E501 | ||
import re # noqa: E501 | ||
|
||
class ChallengeSponsorCreateRequest(Model): | ||
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
Do not edit the class manually. | ||
""" | ||
|
||
def __init__(self, name=None, login=None, roles=None): # noqa: E501 | ||
"""ChallengeSponsorCreateRequest - a model defined in OpenAPI | ||
:param name: The name of this ChallengeSponsorCreateRequest. # noqa: E501 | ||
:type name: str | ||
:param login: The login of this ChallengeSponsorCreateRequest. # noqa: E501 | ||
:type login: str | ||
:param roles: The roles of this ChallengeSponsorCreateRequest. # noqa: E501 | ||
:type roles: List[ChallengeSponsorRole] | ||
""" | ||
self.openapi_types = { | ||
'name': str, | ||
'login': str, | ||
'roles': List[ChallengeSponsorRole] | ||
} | ||
|
||
self.attribute_map = { | ||
'name': 'name', | ||
'login': 'login', | ||
'roles': 'roles' | ||
} | ||
|
||
self._name = name | ||
self._login = login | ||
self._roles = roles | ||
|
||
@classmethod | ||
def from_dict(cls, dikt) -> 'ChallengeSponsorCreateRequest': | ||
"""Returns the dict as a model | ||
:param dikt: A dict. | ||
:type: dict | ||
:return: The ChallengeSponsorCreateRequest of this ChallengeSponsorCreateRequest. # noqa: E501 | ||
:rtype: ChallengeSponsorCreateRequest | ||
""" | ||
return util.deserialize_model(dikt, cls) | ||
|
||
@property | ||
def name(self): | ||
"""Gets the name of this ChallengeSponsorCreateRequest. | ||
:return: The name of this ChallengeSponsorCreateRequest. | ||
:rtype: str | ||
""" | ||
return self._name | ||
|
||
@name.setter | ||
def name(self, name): | ||
"""Sets the name of this ChallengeSponsorCreateRequest. | ||
:param name: The name of this ChallengeSponsorCreateRequest. | ||
:type name: str | ||
""" | ||
if name is None: | ||
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 | ||
|
||
self._name = name | ||
|
||
@property | ||
def login(self): | ||
"""Gets the login of this ChallengeSponsorCreateRequest. | ||
The user or organization account name # noqa: E501 | ||
:return: The login of this ChallengeSponsorCreateRequest. | ||
:rtype: str | ||
""" | ||
return self._login | ||
|
||
@login.setter | ||
def login(self, login): | ||
"""Sets the login of this ChallengeSponsorCreateRequest. | ||
The user or organization account name # noqa: E501 | ||
:param login: The login of this ChallengeSponsorCreateRequest. | ||
:type login: str | ||
""" | ||
if login is not None and len(login) > 25: | ||
raise ValueError("Invalid value for `login`, length must be less than or equal to `25`") # noqa: E501 | ||
if login is not None and len(login) < 3: | ||
raise ValueError("Invalid value for `login`, length must be greater than or equal to `3`") # noqa: E501 | ||
if login is not None and not re.search(r'^[a-z0-9]+(?:-[a-z0-9]+)*$', login): # noqa: E501 | ||
raise ValueError("Invalid value for `login`, must be a follow pattern or equal to `/^[a-z0-9]+(?:-[a-z0-9]+)*$/`") # noqa: E501 | ||
|
||
self._login = login | ||
|
||
@property | ||
def roles(self): | ||
"""Gets the roles of this ChallengeSponsorCreateRequest. | ||
:return: The roles of this ChallengeSponsorCreateRequest. | ||
:rtype: List[ChallengeSponsorRole] | ||
""" | ||
return self._roles | ||
|
||
@roles.setter | ||
def roles(self, roles): | ||
"""Sets the roles of this ChallengeSponsorCreateRequest. | ||
:param roles: The roles of this ChallengeSponsorCreateRequest. | ||
:type roles: List[ChallengeSponsorRole] | ||
""" | ||
|
||
self._roles = roles |
Oops, something went wrong.