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

Commit

Permalink
Add ChallengeSponsors (#190)
Browse files Browse the repository at this point in the history
* 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
tschaffter authored Oct 28, 2021
1 parent 2ac0529 commit cc6696b
Show file tree
Hide file tree
Showing 13 changed files with 986 additions and 1,000 deletions.
543 changes: 290 additions & 253 deletions server/openapi_server/controllers/challenge_controller.py

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions server/openapi_server/dbmodels/challenge_sponsor.py
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
10 changes: 5 additions & 5 deletions server/openapi_server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
from openapi_server.models.challenge_readme_create_request import ChallengeReadmeCreateRequest
from openapi_server.models.challenge_readme_create_response import ChallengeReadmeCreateResponse
from openapi_server.models.challenge_readme_update_request import ChallengeReadmeUpdateRequest
from openapi_server.models.challenge_sponsor import ChallengeSponsor
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_list import ChallengeSponsorList
from openapi_server.models.challenge_sponsor_role import ChallengeSponsorRole
from openapi_server.models.challenge_status import ChallengeStatus
from openapi_server.models.date_range import DateRange
from openapi_server.models.error import Error
Expand All @@ -48,15 +53,10 @@
from openapi_server.models.page_of_org_memberships_all_of import PageOfOrgMembershipsAllOf
from openapi_server.models.page_of_organizations import PageOfOrganizations
from openapi_server.models.page_of_organizations_all_of import PageOfOrganizationsAllOf
from openapi_server.models.page_of_tags import PageOfTags
from openapi_server.models.page_of_tags_all_of import PageOfTagsAllOf
from openapi_server.models.page_of_users import PageOfUsers
from openapi_server.models.page_of_users_all_of import PageOfUsersAllOf
from openapi_server.models.response_page_metadata import ResponsePageMetadata
from openapi_server.models.response_page_metadata_paging import ResponsePageMetadataPaging
from openapi_server.models.tag import Tag
from openapi_server.models.tag_create_request import TagCreateRequest
from openapi_server.models.tag_create_response import TagCreateResponse
from openapi_server.models.user import User
from openapi_server.models.user_all_of import UserAllOf
from openapi_server.models.user_create_request import UserCreateRequest
Expand Down
164 changes: 164 additions & 0 deletions server/openapi_server/models/challenge_sponsor.py
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 server/openapi_server/models/challenge_sponsor_create_request.py
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
Loading

0 comments on commit cc6696b

Please sign in to comment.