Skip to content

Commit

Permalink
Merge pull request #116 from alan-turing-institute/auth-backend
Browse files Browse the repository at this point in the history
Basic backend user management
  • Loading branch information
nbarlowATI authored May 12, 2022
2 parents 6ded5b2 + 12ea428 commit dc394b2
Show file tree
Hide file tree
Showing 23 changed files with 271 additions and 555 deletions.
11 changes: 11 additions & 0 deletions eap_backend/eap_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import (
AssuranceCase,
EAPUser,
TopLevelNormativeGoal,
Context,
SystemDescription,
PropertyClaim,
EvidentialClaim,
Evidence,
)
from .forms import EAPUserChangeForm, EAPUserCreationForm


class EAPUserAdmin(UserAdmin):
add_form = EAPUserCreationForm
form = EAPUserChangeForm
model = EAPUser
list_display = ["email"]


# Register your models here.

admin.site.register(AssuranceCase)
admin.site.register(EAPUser, EAPUserAdmin)
admin.site.register(TopLevelNormativeGoal)
admin.site.register(Context)
admin.site.register(SystemDescription)
Expand Down
14 changes: 14 additions & 0 deletions eap_backend/eap_api/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from .models import EAPUser


class EAPUserCreationForm(UserCreationForm):
class Meta:
model = EAPUser
fields = ("email",)


class EAPUserChangeForm(UserChangeForm):
class Meta:
model = EAPUser
fields = UserChangeForm.Meta.fields
247 changes: 204 additions & 43 deletions eap_backend/eap_api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Generated by Django 3.2.8 on 2021-10-26 11:52
# Generated by Django 3.2.8 on 2022-05-12 10:56

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = []
dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
]

operations = [
migrations.CreateModel(
name="Argument",
name="AssuranceCase",
fields=[
(
"id",
Expand All @@ -24,26 +29,14 @@ class Migration(migrations.Migration):
),
),
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name="AssuranceCase",
fields=[
("description", models.CharField(max_length=1000)),
("created_date", models.DateTimeField(auto_now_add=True)),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
"lock_uuid",
models.CharField(
blank=True, default=None, max_length=50, null=True
),
),
("name", models.CharField(max_length=200)),
("description", models.CharField(max_length=1000)),
("shape", models.IntegerField(default=0)),
],
),
migrations.CreateModel(
Expand All @@ -61,16 +54,20 @@ class Migration(migrations.Migration):
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("created_date", models.DateTimeField(auto_now_add=True)),
("keywords", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
(
"assurance_case",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="goals",
to="eap_api.assurancecase",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="SystemDescription",
Expand All @@ -87,15 +84,19 @@ class Migration(migrations.Migration):
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
("created_date", models.DateTimeField(auto_now_add=True)),
(
"goal_id",
"goal",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="system_description",
to="eap_api.toplevelnormativegoal",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="PropertyClaim",
Expand All @@ -112,15 +113,43 @@ class Migration(migrations.Migration):
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
("created_date", models.DateTimeField(auto_now_add=True)),
(
"claim_type",
models.CharField(
choices=[
("System claim", "System"),
("Project claim", "Project"),
],
default="Project claim",
max_length=32,
),
),
("level", models.PositiveIntegerField()),
(
"goal_id",
"goal",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="property_claims",
to="eap_api.toplevelnormativegoal",
),
),
(
"property_claim",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="property_claims",
to="eap_api.propertyclaim",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="EvidentialClaim",
Expand All @@ -137,15 +166,17 @@ class Migration(migrations.Migration):
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
("created_date", models.DateTimeField(auto_now_add=True)),
(
"goal_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eap_api.argument",
"property_claim",
models.ManyToManyField(
related_name="evidential_claims", to="eap_api.PropertyClaim"
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Evidence",
Expand All @@ -162,16 +193,18 @@ class Migration(migrations.Migration):
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("created_date", models.DateTimeField(auto_now_add=True)),
("URL", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
(
"goal_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eap_api.evidentialclaim",
"evidential_claim",
models.ManyToManyField(
related_name="evidence", to="eap_api.EvidentialClaim"
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Context",
Expand All @@ -188,21 +221,149 @@ class Migration(migrations.Migration):
("name", models.CharField(max_length=200)),
("short_description", models.CharField(max_length=1000)),
("long_description", models.CharField(max_length=3000)),
("shape", models.IntegerField(default=0)),
("created_date", models.DateTimeField(auto_now_add=True)),
(
"goal_id",
"goal",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="context",
to="eap_api.toplevelnormativegoal",
),
),
],
options={
"abstract": False,
},
),
migrations.AddField(
model_name="argument",
name="goal_id",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="eap_api.propertyclaim"
),
migrations.CreateModel(
name="EAPUser",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("password", models.CharField(max_length=128, verbose_name="password")),
(
"last_login",
models.DateTimeField(
blank=True, null=True, verbose_name="last login"
),
),
(
"is_superuser",
models.BooleanField(
default=False,
help_text=(
"Designates that this user has all permissions "
"without explicitly assigning them."
),
verbose_name="superuser status",
),
),
(
"username",
models.CharField(
error_messages={
"unique": "A user with that username already exists."
},
help_text=(
"Required. 150 characters or fewer. "
"Letters, digits and @/./+/-/_ only."
),
max_length=150,
unique=True,
validators=[
django.contrib.auth.validators.UnicodeUsernameValidator()
],
verbose_name="username",
),
),
(
"first_name",
models.CharField(
blank=True, max_length=150, verbose_name="first name"
),
),
(
"last_name",
models.CharField(
blank=True, max_length=150, verbose_name="last name"
),
),
(
"email",
models.EmailField(
blank=True, max_length=254, verbose_name="email address"
),
),
(
"is_staff",
models.BooleanField(
default=False,
help_text=(
"Designates whether the user can log into this "
"admin site."
),
verbose_name="staff status",
),
),
(
"is_active",
models.BooleanField(
default=True,
help_text=(
"Designates whether this user should be treated as "
"active. Unselect this instead of deleting "
"accounts."
),
verbose_name="active",
),
),
(
"date_joined",
models.DateTimeField(
default=django.utils.timezone.now, verbose_name="date joined"
),
),
(
"groups",
models.ManyToManyField(
blank=True,
help_text=(
"The groups this user belongs to. "
"A user will get all permissions granted to each of their "
"groups."
),
related_name="user_set",
related_query_name="user",
to="auth.Group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.Permission",
verbose_name="user permissions",
),
),
],
options={
"verbose_name": "user",
"verbose_name_plural": "users",
"abstract": False,
},
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
]
Loading

0 comments on commit dc394b2

Please sign in to comment.