Verified Commit 6f057659 authored by Peter Stanko's avatar Peter Stanko
Browse files

Use default gitlab url

parent accfa8f5
Pipeline #14825 passed with stage
in 24 minutes and 1 second
......@@ -38,6 +38,9 @@ class Config(object):
PORTAL_LOG_CONFIG = False
PORTAL_DATA_WORKER_DOMAIN = os.getenv('PORTAL_DATA_WORKER_DOMAIN', 'localhost')
LDAP_URL = os.getenv('LDAP_URL', None)
GITLAB_BASE_DOMAIN = "gitlab.fi.muni.cz"
GIT_REPO_BASE = os.getenv('GIT_REPO_BASE', f"git@{GITLAB_BASE_DOMAIN}")
GITLAB_URL = os.getenv('GITLAB_URL', None)
class DevelopmentConfig(Config):
......
......@@ -126,8 +126,8 @@ class SubmissionFileSourceSchema(Schema):
"""Submissions File Source Schema
"""
type = fields.Str(required=True)
url = fields.Str() # git@gitlab.fi.muni.cz:foo/project.git
branch = fields.Str()
url = fields.Str(allow_none=True) # git@gitlab.fi.muni.cz:foo/project.git
branch = fields.Str(allow_none=True)
checkout = fields.Str()
@validates_schema
......
......@@ -64,7 +64,7 @@ class SubmissionsService(GeneralService):
"""
# adding review at submission create is not supported
submission_params = self.process_submission_params(submission_params, project, user=user)
new_submission = Submission(
user=user, project=project, parameters=submission_params)
self.write_entity(new_submission)
......@@ -92,6 +92,7 @@ class SubmissionsService(GeneralService):
def process_new_submission(self) -> AsyncResult:
project = self.submission.project
self.submission.parameters['file_params'] = project.config.file_whitelist
self.write_entity(self.submission)
task = self.create_process_submission_task()
......@@ -199,6 +200,18 @@ class SubmissionsService(GeneralService):
return self.filter_user_avail_submissions(query, roles, groups)
def process_submission_params(self, params: dict, project: Project, user: User):
file_params = params.get('file_params')
file_params['from_dir'] = params.get('from_dir') or project.codename
source = file_params.get('source')
if source and source['type'] == 'git':
source['url'] = source.get('url') or self.__get_default_git_url(project, user)
return params
def __get_default_git_url(self, project: Project, user: User):
git_base = self.flask_app.config.get('GIT_REPO_BASE', 'git@gitlab.fi.muni.cz')
return f"{git_base}/{user.username}/{project.course.codename}"
def nonempty_intersection(provided: list, required: list):
if not required:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment