Skip to content

Commit

Permalink
Adjust to frontend (#20)
Browse files Browse the repository at this point in the history
* Fix Issue with get_or_create

* fix issue with is_active

* small fixes from stef

* fix settings

---------

Co-authored-by: SKairinos <[email protected]>
  • Loading branch information
SalmanAsh and SKairinos authored Sep 6, 2024
1 parent 8d35b8a commit 220182b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion api/auth/backends/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ def authenticate( # type: ignore[override]

try:
return Contributor.objects.get_or_create(
id=contributor_data["id"], defaults=contributor_data
id=contributor_data["id"],
defaults={
"id": contributor_data["id"],
"email": contributor_data["email"],
"name": contributor_data["name"],
"location": contributor_data.get("location"),
"html_url": contributor_data["html_url"],
"avatar_url": contributor_data["avatar_url"],
},
)[0]
# pylint: disable-next=bare-except
except:
Expand Down
2 changes: 1 addition & 1 deletion api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.25 on 2024-08-08 10:28
# Generated by Django 3.2.25 on 2024-09-06 11:54

import django.core.validators
from django.db import migrations, models
Expand Down
2 changes: 2 additions & 0 deletions api/models/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
class Contributor(models.Model):
"""A contributor that contributes to a repo"""

is_active = True

pk: int
id = models.IntegerField(
primary_key=True, help_text=_("The contributor's GitHub user-ID.")
Expand Down
4 changes: 2 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
GH_ORG = "ocadotechnology"
GH_REPO = "codeforlife-workspace"
GH_FILE = "CONTRIBUTING.md"
GH_CLIENT_ID = os.getenv("GITHUB_CLIENT_ID", "replace-me")
GH_CLIENT_SECRET = os.getenv("GITHUB_CLIENT_SECRET", "replace-me")
GH_CLIENT_ID = os.getenv("GH_CLIENT_ID", "Ov23liBErSabQFqROeMg")
GH_CLIENT_SECRET = os.getenv("GH_CLIENT_SECRET", "replace-me")

AUTHENTICATION_BACKENDS = ["api.auth.backends.GitHubBackend"]

Expand Down

0 comments on commit 220182b

Please sign in to comment.