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

Florian aanpassingen #19

Merged
merged 2 commits into from
Apr 4, 2024
Merged
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
21 changes: 21 additions & 0 deletions api/migrations/0027_remove_userprofile_first_name_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.0.1 on 2024-04-04 08:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0026_alter_uploadtask_status'),
]

operations = [
migrations.RemoveField(
model_name='userprofile',
name='first_name',
),
migrations.RemoveField(
model_name='userprofile',
name='last_name',
),
]
2 changes: 0 additions & 2 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def __str__(self):
class UserProfile(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.OneToOneField(User, on_delete=models.CASCADE)
first_name = models.CharField(max_length=50, null=True, blank=True)
last_name = models.CharField(max_length=50, null=True, blank=True)
organisation = models.ForeignKey(
Organisation, on_delete=models.CASCADE, null=True, blank=True
)
Expand Down
17 changes: 17 additions & 0 deletions gmn/migrations/0016_gmn_color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.1 on 2024-04-04 07:42

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("gmn", "0015_alter_gmn_delivery_accountable_party_and_more"),
]

operations = [
migrations.AddField(
model_name="gmn",
name="color",
field=models.CharField(blank=True, max_length=7, null=True),
),
]
18 changes: 18 additions & 0 deletions gmn/migrations/0017_alter_gmn_color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.1 on 2024-04-04 08:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('gmn', '0016_gmn_color'),
]

operations = [
migrations.AlterField(
model_name='gmn',
name='color',
field=models.CharField(blank=True, default=None, max_length=7, null=True),
),
]
12 changes: 12 additions & 0 deletions gmn/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import random
import uuid

from django.db import models

from api.models import Organisation


def generate_random_color():
"""Generate a random hex color code."""
return f"#{random.randint(0, 0xFFFFFF):06x}"


class GMN(models.Model):
"""Groundwater Monitoring Network

Expand All @@ -25,10 +31,16 @@ class GMN(models.Model):
start_date_monitoring = models.DateField(null=True)
object_registration_time = models.DateTimeField(null=True)
registration_status = models.CharField(max_length=50, null=True)
color = models.CharField(max_length=7, null=True, blank=True, default=None)

def __str__(self):
return self.bro_id

def save(self, *args, **kwargs):
if not self.color:
self.color = generate_random_color()
super().save(*args, **kwargs)

class Meta:
verbose_name_plural = "GMN's"

Expand Down
Loading