diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-24 20:51:33 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-24 20:51:33 +0100 |
commit | 708b983c9cb0895ae0d205013d46a17020c4ef73 (patch) | |
tree | 3583151f0dc95b1be2462207d20dbee0a53fd866 /ctrack | |
parent | 7494bebcd8c531df0680e96952ffeceb34fd0a57 (diff) |
removed oes field from user - about to make a profile model
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/users/admin.py | 4 | ||||
-rw-r--r-- | ctrack/users/migrations/0004_auto_20200524_1945.py | 23 | ||||
-rw-r--r-- | ctrack/users/models.py | 6 | ||||
-rw-r--r-- | ctrack/users/tests/factories.py | 1 | ||||
-rw-r--r-- | ctrack/users/tests/test_models.py | 2 | ||||
-rw-r--r-- | ctrack/users/tests/test_views.py | 10 |
6 files changed, 32 insertions, 14 deletions
diff --git a/ctrack/users/admin.py b/ctrack/users/admin.py index 28e91eb..120cc64 100644 --- a/ctrack/users/admin.py +++ b/ctrack/users/admin.py @@ -12,8 +12,6 @@ class UserAdmin(auth_admin.UserAdmin): form = UserChangeForm add_form = UserCreationForm - fieldsets = ( - ("User", {"fields": ("name", "oes_user")}), - ) + auth_admin.UserAdmin.fieldsets + fieldsets = (("User", {"fields": ("name",)}),) + auth_admin.UserAdmin.fieldsets list_display = ["username", "name", "is_superuser"] search_fields = ["name"] diff --git a/ctrack/users/migrations/0004_auto_20200524_1945.py b/ctrack/users/migrations/0004_auto_20200524_1945.py new file mode 100644 index 0000000..8839fd2 --- /dev/null +++ b/ctrack/users/migrations/0004_auto_20200524_1945.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.5 on 2020-05-24 19:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0003_auto_20200522_1527'), + ] + + operations = [ + migrations.CreateModel( + name='UserProfile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + migrations.RemoveField( + model_name='user', + name='oes_user', + ), + ] diff --git a/ctrack/users/models.py b/ctrack/users/models.py index df23623..76dabf3 100644 --- a/ctrack/users/models.py +++ b/ctrack/users/models.py @@ -1,4 +1,5 @@ from django.contrib.auth.models import AbstractUser +from django.db import models from django.db.models import BooleanField, CharField from django.urls import reverse from django.utils.translation import ugettext_lazy as _ @@ -9,7 +10,10 @@ class User(AbstractUser): # First Name and Last Name do not cover name patterns # around the globe. name = CharField(_("Name of User"), blank=True, max_length=255) - oes_user = BooleanField(default=False, verbose_name="OES User") def get_absolute_url(self): return reverse("users:detail", kwargs={"username": self.username}) + + +class UserProfile(models.Model): + pass diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py index 700d9b4..b4ddad0 100644 --- a/ctrack/users/tests/factories.py +++ b/ctrack/users/tests/factories.py @@ -8,7 +8,6 @@ class UserFactory(DjangoModelFactory): username = Faker("user_name") email = Faker("email") name = Faker("name") - oes_user = False @post_generation def password(self, create: bool, extracted: Sequence[Any], **kwargs): diff --git a/ctrack/users/tests/test_models.py b/ctrack/users/tests/test_models.py index fb2eade..c429b9c 100644 --- a/ctrack/users/tests/test_models.py +++ b/ctrack/users/tests/test_models.py @@ -13,4 +13,4 @@ def test_user_is_person_object(user: User): """User comes from ctrack.conftest. """ - assert user.oes_user is False + assert user diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index 8b923f6..561c540 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -53,13 +53,8 @@ def test_profile_view_contains_organisation_information(): This is where users are redirected to when they log in and where I want to capture information about the user - particularly if they are an OES user. """ - org = OrganisationFactory.create() user = get_user_model().objects.create_user( - username="testy", - email="testy@test.com", - password="test1020", - oes_user=True, - organisation=org, + username="testy", email="testy@test.com", password="test1020" ) factory = RequestFactory() request = factory.get(f"/users/{user.username}") @@ -68,6 +63,5 @@ def test_profile_view_contains_organisation_information(): request.user = user response = UserDetailView.as_view()(request, username=user.username) assert response.status_code == 200 - assert response.context_data["object"].oes_user is True # TODO - work out how we can attach an organisation to the User model - assert response.context_data["object"].organisation.name == org.name + assert response.context_data["object"] |