From c5d8157670ea2b7f448fc41ca790b25c03a4bedb Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Thu, 7 Jun 2018 16:34:59 +0100 Subject: Replace GitHub with GitLab across the project --- pysite/migrations/tables/code_jam_participants/v2.py | 12 ++++++++++++ pysite/tables.py | 2 +- pysite/views/error_handlers/http_4xx.py | 3 ++- pysite/views/error_handlers/http_5xx.py | 4 ++-- pysite/views/main/jams/profile.py | 6 +++--- pysite/views/main/redirects/github.py | 2 +- pysite/views/main/redirects/gitlab.py | 8 ++++++++ pysite/views/wiki/edit.py | 2 +- 8 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 pysite/migrations/tables/code_jam_participants/v2.py create mode 100644 pysite/views/main/redirects/gitlab.py (limited to 'pysite') diff --git a/pysite/migrations/tables/code_jam_participants/v2.py b/pysite/migrations/tables/code_jam_participants/v2.py new file mode 100644 index 00000000..858da279 --- /dev/null +++ b/pysite/migrations/tables/code_jam_participants/v2.py @@ -0,0 +1,12 @@ +def run(db, table, table_obj): + """ + GitHub usernames -> Store as GitLab username, this will be correct for most jammers + """ + + for document in db.get_all(table): + if "github_username" in document: + document["gitlab_username"] = document["github_username"] + del document["github_username"] + + db.insert(table, document, conflict="replace", durability="soft") + db.sync(table) diff --git a/pysite/tables.py b/pysite/tables.py index 7e43fe87..87e6cf47 100644 --- a/pysite/tables.py +++ b/pysite/tables.py @@ -112,7 +112,7 @@ TABLES = { primary_key="id", keys=sorted([ "id", # str - "github_username", # str + "gitlab_username", # str "timezone" # str ]) ), diff --git a/pysite/views/error_handlers/http_4xx.py b/pysite/views/error_handlers/http_4xx.py index 69c0bdda..1667adcf 100644 --- a/pysite/views/error_handlers/http_4xx.py +++ b/pysite/views/error_handlers/http_4xx.py @@ -26,5 +26,6 @@ class Error400View(ErrorView): return self.render( "errors/error.html", code=error.code, req=request, error_title=error_desc, error_message=f"{error_desc} If you believe we have made a mistake, please " - "open an issue on our GitHub." + "" + "open an issue on our GitLab." ), error.code diff --git a/pysite/views/error_handlers/http_5xx.py b/pysite/views/error_handlers/http_5xx.py index 5a4fbdc2..c9ffa007 100644 --- a/pysite/views/error_handlers/http_5xx.py +++ b/pysite/views/error_handlers/http_5xx.py @@ -36,6 +36,6 @@ class Error500View(ErrorView): "errors/error.html", code=error.code, req=request, error_title=error_desc, error_message="An error occurred while processing this request, please try " "again later. If you believe we have made a mistake, please " - "file an issue on our" - " GitHub." + "file an issue on our" + " GitLab." ), error.code diff --git a/pysite/views/main/jams/profile.py b/pysite/views/main/jams/profile.py index f84534e6..e918c135 100644 --- a/pysite/views/main/jams/profile.py +++ b/pysite/views/main/jams/profile.py @@ -45,13 +45,13 @@ class JamsProfileView(RouteView, DBMixin, OAuthMixin): if not participant: participant = {"id": self.user_data["user_id"]} - github_username = request.form.get("github_username") + gitlab_username = request.form.get("gitlab_username") timezone = request.form.get("timezone") - if not github_username or not timezone: + if not gitlab_username or not timezone: return BadRequest() - participant["github_username"] = github_username + participant["gitlab_username"] = gitlab_username participant["timezone"] = timezone self.db.insert(self.table_name, participant, conflict="replace") diff --git a/pysite/views/main/redirects/github.py b/pysite/views/main/redirects/github.py index 3c74ace3..816d165f 100644 --- a/pysite/views/main/redirects/github.py +++ b/pysite/views/main/redirects/github.py @@ -4,5 +4,5 @@ from pysite.base_route import RedirectView class GitHubView(RedirectView): path = "/github" name = "github" - page = "https://github.com/discord-python/" + page = "https://gitlab.com/discord-python/" code = 302 diff --git a/pysite/views/main/redirects/gitlab.py b/pysite/views/main/redirects/gitlab.py new file mode 100644 index 00000000..eda0e179 --- /dev/null +++ b/pysite/views/main/redirects/gitlab.py @@ -0,0 +1,8 @@ +from pysite.base_route import RedirectView + + +class GitLabView(RedirectView): + path = "/gitlab" + name = "gitlab" + page = "https://gitlab.com/discord-python/" + code = 302 diff --git a/pysite/views/wiki/edit.py b/pysite/views/wiki/edit.py index f6f61272..cc121cc6 100644 --- a/pysite/views/wiki/edit.py +++ b/pysite/views/wiki/edit.py @@ -156,7 +156,7 @@ class EditView(RouteView, DBMixin): headers = { "Authorization": f"token {GITHUB_TOKEN}", - "User-Agent": "Discord Python Wiki (https://github.com/discord-python)" + "User-Agent": "Discord Python Wiki (https://gitlab.com/discord-python)" } gist = requests.post("https://api.github.com/gists", -- cgit v1.2.3