Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the organisation models #59

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion request_a_govuk_domain/request/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
from django.contrib.auth.models import User
from django.contrib.auth.models import Group

from .models import Application, CentralGovernmentAttributes, Review
from .models import (
Application,
CentralGovernmentAttributes,
Review,
Registrar,
Registrant,
)


class DomainRegistrationUserAdmin(UserAdmin):
Expand Down Expand Up @@ -38,10 +44,20 @@ class ApplicationAdmin(admin.ModelAdmin):
inlines = [CentralGovernmentAttributesInline, ReviewInline]


class RegistrarAdmin(admin.ModelAdmin):
model = Registrar


class RegistrantAdmin(admin.ModelAdmin):
model = Registrant


admin.site.unregister(User)
admin.site.register(User, DomainRegistrationUserAdmin)

admin.site.unregister(Group)
admin.site.register(Group, DomainRegistrationGroupAdmin)

admin.site.register(Application, ApplicationAdmin)
admin.site.register(Registrar, RegistrarAdmin)
admin.site.register(Registrant, RegistrantAdmin)
72 changes: 31 additions & 41 deletions request_a_govuk_domain/request/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-03-08 18:51
# Generated by Django 4.2.11 on 2024-03-12 19:53

from django.conf import settings
from django.db import migrations, models
Expand Down Expand Up @@ -39,21 +39,6 @@ class Migration(migrations.Migration):
),
],
),
migrations.CreateModel(
name="Organisation",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField()),
],
),
migrations.CreateModel(
name="Person",
fields=[
Expand Down Expand Up @@ -81,23 +66,22 @@ class Migration(migrations.Migration):
name="Registrant",
fields=[
(
"organisation_ptr",
models.OneToOneField(
"id",
models.BigAutoField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="request.organisation",
verbose_name="ID",
),
),
("name", models.CharField()),
(
"type",
models.CharField(
choices=[
(
"Central government department or agency",
"Central Goverment",
"Central Government",
),
(
"Non-departmental body - also known as an arm's length body",
Expand All @@ -120,25 +104,28 @@ class Migration(migrations.Migration):
),
),
],
bases=("request.organisation",),
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Registrar",
fields=[
(
"organisation_ptr",
models.OneToOneField(
"id",
models.BigAutoField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="request.organisation",
verbose_name="ID",
),
),
("name", models.CharField()),
("email_address", models.EmailField(max_length=320)),
],
bases=("request.organisation",),
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Review",
Expand Down Expand Up @@ -188,6 +175,9 @@ class Migration(migrations.Migration):
),
),
],
options={
"default_related_name": "review",
},
),
migrations.CreateModel(
name="HistoricalReview",
Expand Down Expand Up @@ -309,34 +299,34 @@ class Migration(migrations.Migration):
),
migrations.AddField(
model_name="application",
name="registrant_person",
name="registrant_org",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="registrant_application",
to="request.person",
on_delete=django.db.models.deletion.CASCADE, to="request.registrant"
),
),
migrations.AddField(
model_name="application",
name="responsible_person",
name="registrant_person",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="responsible_application",
related_name="registrant_application",
to="request.person",
),
),
migrations.AddField(
model_name="application",
name="registrant_org",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="request.registrant"
name="registrar",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="request.registrar"
),
),
migrations.AddField(
model_name="application",
name="registrar",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="request.registrar"
name="responsible_person",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="responsible_application",
to="request.person",
),
),
]

This file was deleted.

3 changes: 3 additions & 0 deletions request_a_govuk_domain/request/models/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class Organisation(models.Model):
def __str__(self):
return self.name

class Meta:
abstract = True


class RegistrantTypeChoices(models.TextChoices):
central_government = "Central government department or agency"
Expand Down
2 changes: 1 addition & 1 deletion request_a_govuk_domain/static/staticfiles.json

Large diffs are not rendered by default.

44 changes: 10 additions & 34 deletions seed/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,59 +60,35 @@
}
},
{
"model": "request.organisation",
"model": "request.registrant",
"pk": 1,
"fields": {
"name": "The Registrar Co."
}
},
{
"model": "request.organisation",
"pk": 2,
"fields": {
"name": "The Ministry of Domains"
}
},
{
"model": "request.organisation",
"pk": 3,
"fields": {
"name": "The Registrar Co."
}
},
{
"model": "request.organisation",
"pk": 4,
"fields": {
"name": "The Ministry of Domains"
"name": "HMRC",
"type": "Central government department or agency"
}
},
{
"model": "request.registrant",
"pk": 2,
"fields": {
"type": ""
}
},
{
"model": "request.registrant",
"pk": 4,
"fields": {
"type": ""
"name": "Littleton Parish Council",
"type": "Parish, town or community council"
}
},
{
"model": "request.registrar",
"pk": 1,
"fields": {
"email_address": ""
"name": "We Register Ltd",
"email_address": "[email protected]"
}
},
{
"model": "request.registrar",
"pk": 3,
"pk": 2,
"fields": {
"email_address": ""
"name": "Best Registrar Ltd",
"email_address": "[email protected]"
}
},
{
Expand Down