diff --git a/app/admin.py b/app/admin.py index 98f3591d..c1f86dc4 100644 --- a/app/admin.py +++ b/app/admin.py @@ -15,7 +15,8 @@ class CustomUserAdmin(UserAdmin): 'fields': ( 'profile_photo', 'description', - 'is_advisor' + 'is_advisor', + 'lattes_url' ), }, ), diff --git a/app/graphs.py b/app/graphs.py index 38edf106..3ab46adb 100644 --- a/app/graphs.py +++ b/app/graphs.py @@ -7,18 +7,21 @@ def generateAllMotes24hRaw(): - for n in range(1, 3): + for n in range(1, 4): idList = list(Device.objects.filter( type=n, is_authorized=True).values_list('id', flat=True)) dataFrameList = [] mediaRoot = settings.MEDIA_ROOT - if (n == 1): + if n == 1: mediaPath = f'graphs/allWMoteDevices24hRaw.html' collectionUnit = 'Consumo(L)' - else: + elif n == 2: mediaPath = f'graphs/allEMoteDevices24hRaw.html' collectionUnit = 'Consumo(Watts)' + else: + mediaPath = 'graphs/allGMoteDevices24hRaw.html' + collectionUnit = 'Consumo(m³)' for i in idList: counter = 0 diff --git a/app/migrations/0008_extenduser_lattes_url_alter_device_type_and_more.py b/app/migrations/0008_extenduser_lattes_url_alter_device_type_and_more.py new file mode 100644 index 00000000..07daf49f --- /dev/null +++ b/app/migrations/0008_extenduser_lattes_url_alter_device_type_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.1 on 2024-05-24 00:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0007_device_is_authorized'), + ] + + operations = [ + migrations.AddField( + model_name='extenduser', + name='lattes_url', + field=models.URLField(blank=True, null=True), + ), + migrations.AlterField( + model_name='device', + name='type', + field=models.IntegerField(choices=[(0, 'Not Defined'), (1, 'Water'), (2, 'Energy'), (3, 'Gas')], default=0), + ), + migrations.AlterField( + model_name='graph', + name='type', + field=models.IntegerField(choices=[(0, 'Not Defined'), (1, 'All WMote Devices | 24h | Raw'), (2, 'All EMote Devices | 24h | Raw'), (3, 'All GMote Devices | 24h | Raw')], default=0), + ), + ] diff --git a/app/models.py b/app/models.py index e38026e2..34c523f1 100644 --- a/app/models.py +++ b/app/models.py @@ -9,13 +9,15 @@ class DeviceTypes(models.IntegerChoices): none = 0, 'Not Defined', water = 1, 'Water', - energy = 2, 'Energy' + energy = 2, 'Energy', + gas = 3, 'Gas' class GraphsTypes(models.IntegerChoices): none = 0, 'Not Defined', allWMoteDevices24hRaw = 1, 'All WMote Devices | 24h | Raw', allEMoteDevices24hRaw = 2, 'All EMote Devices | 24h | Raw', + allGMoteDevices24hRaw = 3, 'All GMote Devices | 24h | Raw' class ExtendUser(AbstractUser): @@ -23,6 +25,7 @@ class ExtendUser(AbstractUser): upload_to='profile/', default='defaults/profile_default.png') description = models.CharField(max_length=256, blank=True) is_advisor = models.BooleanField(default=False) + lattes_url = models.URLField(max_length=200, blank=True, null=True) def __str__(self): if (self.first_name) and (self.last_name): diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 8f90273c..0d11a57d 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -17,6 +17,9 @@
{{member.description}}
+ {% if member.lattes_url %} + + {% endif %} {% endfor %} @@ -39,6 +42,9 @@{{member.description}}
+ {% if member.lattes_url %} + + {% endif %} {% endfor %} diff --git a/app/views.py b/app/views.py index 8b35716b..94472c11 100644 --- a/app/views.py +++ b/app/views.py @@ -22,8 +22,9 @@ def dashboard(request): allWMotes24hRaw = Graph.objects.get(type=1) allEMotes24hRaw = Graph.objects.get(type=2) + allGMotes24hRaw = Graph.objects.get(type=3) - return render(request, 'dashboard.html', {'wMote': allWMotes24hRaw, 'eMote': allEMotes24hRaw}) + return render(request, 'dashboard.html', {'wMote': allWMotes24hRaw, 'eMote': allEMotes24hRaw, 'gMote': allGMotes24hRaw}) def members(request):