Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/origin_save.py
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if bypass_pending_review: | ||||
SaveAuthorizedOrigin.objects.get_or_create(url=origin_url) | SaveAuthorizedOrigin.objects.get_or_create(url=origin_url) | ||||
return SAVE_REQUEST_ACCEPTED | return SAVE_REQUEST_ACCEPTED | ||||
else: | else: | ||||
return SAVE_REQUEST_PENDING | return SAVE_REQUEST_PENDING | ||||
# map visit type to scheduler task | # map visit type to scheduler task | ||||
# TODO: do not hardcode the task name here (T1157) | # TODO: do not hardcode the task name here (T1157) | ||||
_visit_type_task = {"git": "load-git", "hg": "load-hg", "svn": "load-svn"} | _visit_type_task = { | ||||
"git": "load-git", | |||||
"hg": "load-hg", | |||||
"svn": "load-svn", | |||||
"cvs": "load-cvs", | |||||
} | |||||
_visit_type_task_privileged = { | _visit_type_task_privileged = { | ||||
"archives": "load-archive-files", | "archives": "load-archive-files", | ||||
} | } | ||||
# map scheduler task status to origin save status | # map scheduler task status to origin save status | ||||
_save_task_status = { | _save_task_status = { | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | def _check_visit_type_savable(visit_type: str, privileged_user: bool = False) -> None: | ||||
if visit_type not in visit_type_tasks: | if visit_type not in visit_type_tasks: | ||||
allowed_visit_types = ", ".join(visit_type_tasks) | allowed_visit_types = ", ".join(visit_type_tasks) | ||||
raise BadInputExc( | raise BadInputExc( | ||||
f"Visit of type {visit_type} can not be saved! " | f"Visit of type {visit_type} can not be saved! " | ||||
f"Allowed types are the following: {allowed_visit_types}" | f"Allowed types are the following: {allowed_visit_types}" | ||||
) | ) | ||||
_validate_url = URLValidator(schemes=["http", "https", "svn", "git"]) | _validate_url = URLValidator( | ||||
schemes=["http", "https", "svn", "git", "rsync", "pserver", "ssh"] | |||||
) | |||||
def _check_origin_url_valid(origin_url: str) -> None: | def _check_origin_url_valid(origin_url: str) -> None: | ||||
try: | try: | ||||
_validate_url(origin_url) | _validate_url(origin_url) | ||||
except ValidationError: | except ValidationError: | ||||
raise BadInputExc( | raise BadInputExc( | ||||
"The provided origin url (%s) is not valid!" % escape(origin_url) | "The provided origin url (%s) is not valid!" % escape(origin_url) | ||||
▲ Show 20 Lines • Show All 697 Lines • Show Last 20 Lines |