-
Notifications
You must be signed in to change notification settings - Fork 1
Add HeaProfileViewSet and UserViewSet api endpoints see HEA-580 #130
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
Changes from 1 commit
e9ec6aa
ba39d57
ff9fc09
3c49812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Generated by Django 5.1.1 on 2024-11-17 15:34 | ||
|
|
||
| import django.db.models.deletion | ||
| import django.utils.timezone | ||
| import model_utils.fields | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("auth", "0012_alter_user_first_name_max_length"), | ||
| ("common", "0009_countryclassifiedproductaliases_aliases"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="HeaProfile", | ||
| fields=[ | ||
| ( | ||
| "created", | ||
| model_utils.fields.AutoCreatedField( | ||
| default=django.utils.timezone.now, editable=False, verbose_name="created" | ||
| ), | ||
| ), | ||
| ( | ||
| "modified", | ||
| model_utils.fields.AutoLastModifiedField( | ||
| default=django.utils.timezone.now, editable=False, verbose_name="modified" | ||
| ), | ||
| ), | ||
| ( | ||
| "user", | ||
| models.OneToOneField( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| primary_key=True, | ||
| serialize=False, | ||
| to=settings.AUTH_USER_MODEL, | ||
| ), | ||
| ), | ||
| ("expert", models.BooleanField(default=False)), | ||
| ("skip_tour", models.BooleanField(default=False)), | ||
| ("tour_last_viewed", models.DateField(null=True)), | ||
| ("livelihood_explorer_data", models.JSONField(blank=True, default=dict, null=True)), | ||
| ], | ||
| options={ | ||
| "verbose_name": "hea user profile", | ||
| "verbose_name_plural": "hea user profiles", | ||
| }, | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import operator | ||
| from functools import reduce | ||
|
|
||
| from django.contrib.auth.models import User | ||
| from django.core import validators | ||
| from django.core.cache import cache | ||
| from django.core.exceptions import ObjectDoesNotExist, ValidationError | ||
|
|
@@ -950,3 +951,23 @@ class Meta: | |
| fields=["country", "product"], name="common_countryclassified_country_code_product_code_uniq" | ||
| ) | ||
| ] | ||
|
|
||
|
|
||
| class HeaProfile(Model): | ||
| """ | ||
| A profile to store data associated with a user to be used by the Livelihoods Explorer | ||
| to create a dynamic user experience. | ||
| """ | ||
|
|
||
| user = models.OneToOneField(User, on_delete=CASCADE, primary_key=True, unique=True) | ||
| expert = models.BooleanField(default=False) | ||
|
||
| skip_tour = models.BooleanField(default=False) | ||
| tour_last_viewed = models.DateField(null=True) | ||
| livelihood_explorer_data = models.JSONField(default=dict, null=True, blank=True) | ||
|
||
|
|
||
| def __str__(self): | ||
| return f"hea_profile: {str(self.user)}" | ||
|
||
|
|
||
| class Meta: | ||
| verbose_name = _("hea user profile") | ||
| verbose_name_plural = _("hea user profiles") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,9 @@ | |
| ClassifiedProductViewSet, | ||
| CountryViewSet, | ||
| CurrencyViewSet, | ||
| HeaProfileViewSet, | ||
| UnitOfMeasureViewSet, | ||
| UserViewSet, | ||
| ) | ||
| from metadata.viewsets import ( | ||
| HazardCategoryViewSet, | ||
|
|
@@ -67,6 +69,8 @@ | |
| router.register(r"currency", CurrencyViewSet) | ||
| router.register(r"unitofmeasure", UnitOfMeasureViewSet) | ||
| router.register(r"classifiedproduct", ClassifiedProductViewSet) | ||
| router.register(r"user", UserViewSet) | ||
| router.register(r"heaprofile", HeaProfileViewSet) | ||
|
||
|
|
||
| # Metadata | ||
| router.register(r"livelihoodcategory", LivelihoodCategoryViewSet) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A profile to store data associated with a user to enable a customized user experience.