Skip to content

Commit

Permalink
fix settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Nov 5, 2024
1 parent c2b927d commit e81503e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ name = "pypi"
# 5. Run `pipenv install --dev` in your terminal.

[packages]
codeforlife = {ref = "v0.20.0", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}
codeforlife = {ref = "contributor-backend-21", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}
# 🚫 Don't add [packages] below that are inherited from the CFL package.

[dev-packages]
codeforlife = {ref = "v0.20.0", git = "https://github.com/ocadotechnology/codeforlife-package-python.git", extras = ["dev"]}
codeforlife = {ref = "contributor-backend-21", git = "https://github.com/ocadotechnology/codeforlife-package-python.git", extras = ["dev"]}
# codeforlife = {file = "../codeforlife-package-python", editable = true, extras = ["dev"]}
# 🚫 Don't add [dev-packages] below that are inherited from the CFL package.

Expand Down
6 changes: 3 additions & 3 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 19 additions & 50 deletions api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Generated by Django 3.2.25 on 2024-09-10 15:33
# Generated by Django 3.2.25 on 2024-11-05 12:23

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand All @@ -15,16 +16,12 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Contributor',
fields=[
('id', models.IntegerField(
help_text="The contributor's GitHub user-ID.",
primary_key=True, serialize=False)),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('id', models.IntegerField(help_text="The contributor's GitHub user-ID.", primary_key=True, serialize=False)),
('name', models.TextField(verbose_name='name')),
('location',
models.TextField(null=True, verbose_name='location')),
('location', models.TextField(null=True, verbose_name='location')),
('html_url', models.TextField(verbose_name='html url')),
('avatar_url', models.TextField(verbose_name='avatar url')),
('last_login', models.DateTimeField(blank=True, null=True,
verbose_name='last login')),
],
options={
'verbose_name': 'contributor',
Expand All @@ -34,15 +31,10 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Session',
fields=[
('session_key',
models.CharField(max_length=40, primary_key=True,
serialize=False, verbose_name='session key')),
('session_key', models.CharField(max_length=40, primary_key=True, serialize=False, verbose_name='session key')),
('session_data', models.TextField(verbose_name='session data')),
('expire_date', models.DateTimeField(db_index=True,
verbose_name='expire date')),
('contributor', models.OneToOneField(blank=True, null=True,
on_delete=django.db.models.deletion.CASCADE,
to='api.contributor')),
('expire_date', models.DateTimeField(db_index=True, verbose_name='expire date')),
('contributor', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='api.contributor')),
],
options={
'verbose_name': 'session',
Expand All @@ -53,16 +45,11 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='ContributorEmail',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254, unique=True,
verbose_name='email')),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254, unique=True, verbose_name='email')),
('is_primary', models.BooleanField(verbose_name='is primary')),
('is_public', models.BooleanField(verbose_name='is public')),
('contributor',
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='emails',
to='api.contributor')),
('contributor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emails', to='api.contributor')),
],
options={
'verbose_name': 'contributor email',
Expand All @@ -72,18 +59,10 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='AgreementSignature',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('agreement_id', models.CharField(
help_text='Commit ID of the contribution agreement in workspace.',
max_length=40,
validators=[django.core.validators.MinLengthValidator(40)],
verbose_name='agreement id')),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('agreement_id', models.CharField(help_text='Commit ID of the contribution agreement in workspace.', max_length=40, validators=[django.core.validators.MinLengthValidator(40)], verbose_name='agreement id')),
('signed_at', models.DateTimeField(verbose_name='signed at')),
('contributor',
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='agreement_signatures',
to='api.contributor')),
('contributor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='agreement_signatures', to='api.contributor')),
],
options={
'verbose_name': 'agreement signature',
Expand All @@ -93,18 +72,10 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Repository',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('gh_id', models.IntegerField(
help_text='Github ID of the repo a contributor has contributed to.',
verbose_name='GitHub ID')),
('points', models.IntegerField(default=0,
help_text='Story points the contributor closed for this repository.',
verbose_name='points')),
('contributor',
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='repositories',
to='api.contributor')),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('gh_id', models.IntegerField(help_text='Github ID of the repo a contributor has contributed to.', verbose_name='GitHub ID')),
('points', models.IntegerField(default=0, help_text='Story points the contributor closed for this repository.', verbose_name='points')),
('contributor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='repositories', to='api.contributor')),
],
options={
'verbose_name': 'repository',
Expand All @@ -114,9 +85,7 @@ class Migration(migrations.Migration):
),
migrations.AddConstraint(
model_name='contributoremail',
constraint=models.UniqueConstraint(
condition=models.Q(('is_primary', True)),
fields=('contributor',), name='contributor__is_primary'),
constraint=models.UniqueConstraint(condition=models.Q(('is_primary', True)), fields=('contributor',), name='contributor__is_primary'),
),
migrations.AlterUniqueTogether(
name='agreementsignature',
Expand Down
9 changes: 6 additions & 3 deletions api/models/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import requests
from codeforlife.types import JsonDict
from django.contrib.auth.models import AbstractBaseUser
from django.db import models
from django.db.models import QuerySet
from django.utils import timezone
Expand All @@ -24,15 +25,18 @@
TypedModelMeta = object


class Contributor(models.Model):
class Contributor(AbstractBaseUser):
"""A contributor that contributes to a repo"""

USERNAME_FIELD = "id"

agreement_signatures: QuerySet["AgreementSignature"]
emails: QuerySet["ContributorEmail"]
repositories: QuerySet["Repository"]
session: "Session"

is_active = True
# Contributors log in with their GitHub account.
password = None # type: ignore[assignment]

pk: int
id = models.IntegerField(
Expand All @@ -42,7 +46,6 @@ class Contributor(models.Model):
location = models.TextField(_("location"), null=True)
html_url = models.TextField(_("html url"))
avatar_url = models.TextField(_("avatar url"))
last_login = models.DateTimeField(_("last login"), blank=True, null=True)

class Meta(TypedModelMeta):
verbose_name = _("contributor")
Expand Down
5 changes: 5 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
INSTALLED_APPS.remove("portal")
INSTALLED_APPS.remove("common")

# Auth user model
# https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#substituting-a-custom-user-model

AUTH_USER_MODEL = "api.contributor"

# Authentication backends
# https://docs.djangoproject.com/en/3.2/ref/settings/#authentication-backends

Expand Down

0 comments on commit e81503e

Please sign in to comment.