From 83a6db9178e51c44b88c31f6f1ffbbd024871bf3 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Tue, 4 Feb 2025 18:15:32 -0800
Subject: [PATCH 01/20] fixed link to organization/create
---
login/views.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/login/views.py b/login/views.py
index 340807df..03af28ec 100644
--- a/login/views.py
+++ b/login/views.py
@@ -172,8 +172,9 @@ def get_context_data(self, **kwargs):
return context
class OrganizationAdminCreateView(SuccessMessageMixin, CreateView):
+ model = Organization
+ template_name = 'login/organization_create.html'
fields = ['name', 'description']
- #template_name = 'login/group_create.html'
def get_success_message(self, cleaned_data):
return "Successfully created organization '{}'".format(cleaned_data['name'])
From be204f44cc0bdb4aa6467ce4f8c273c4c7d9ed28 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Tue, 11 Feb 2025 14:59:59 -0800
Subject: [PATCH 02/20] Sofia's create/detail organization changes
---
templates/login/organization_create.html | 48 ++++++++++++++++++------
templates/login/organization_detail.html | 43 +++++++++++++++++----
2 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/templates/login/organization_create.html b/templates/login/organization_create.html
index 9087b7c3..52543246 100644
--- a/templates/login/organization_create.html
+++ b/templates/login/organization_create.html
@@ -6,11 +6,18 @@
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/templates/login/organization_detail.html b/templates/login/organization_detail.html
index 370b8636..4b2aad22 100644
--- a/templates/login/organization_detail.html
+++ b/templates/login/organization_detail.html
@@ -6,32 +6,61 @@
+
-
-
{% trans "Organization" %}
-
-
{% trans "Details" %}:
+
+
{% trans "Organization Details" %}
{% trans "Name" %}:
{{ organization.name }}
+
{% trans "Description" %}:
- {{ organization.description }}
+ {{ organization.description|default:"{% trans 'No description provided.' %}"|safe }}
+
+
+ {% if organization.permissions.all %}
+
{% trans "Organization Permissions" %}
+
+ {% for permission in organization.permissions.all %}
+ - {{ permission.name }}
+ {% endfor %}
+
+ {% else %}
+
{% trans "Organization Permissions" %}
+
{% trans "No permissions assigned." %}
+ {% endif %}
+
+
+ {% if organization.ambulances.all %}
+
{% trans "Ambulances in this Organization" %}
+
+ {% for ambulance in organization.ambulances.all %}
+ - {{ ambulance.name }}
+ {% endfor %}
+
+ {% else %}
+
{% trans "Ambulances in this Organization" %}
+
{% trans "No ambulances assigned." %}
+ {% endif %}
-{% endblock %}
+{% endblock %}
\ No newline at end of file
From b6a976b776872e1915216987136314ef04d51e2f Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Tue, 11 Feb 2025 17:29:36 -0800
Subject: [PATCH 03/20] Onboarding fixes
Changed default dockerfile to mac version
Changed from CLRF to LF again (somehow)
---
Dockerfile | 8 ++++++--
login/tests/setup_data.py | 5 +++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 8bb62063..db8ef972 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,8 +14,12 @@ RUN set -x && \
rsync
# Install node
-# RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
-RUN apt-get install -y nodejs npm
+#For windows
+#RUN apt-get install -y nodejs npm
+
+#For mac
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
+RUN nvm install node
# Build variables
ARG BUILD_APP_HOME=/app
diff --git a/login/tests/setup_data.py b/login/tests/setup_data.py
index 1249091a..8b15ee67 100644
--- a/login/tests/setup_data.py
+++ b/login/tests/setup_data.py
@@ -12,6 +12,7 @@
from hospital.models import Hospital
from equipment.models import EquipmentType, Equipment, EquipmentHolder, EquipmentItem
+from login.models import Organization
class TestSetupData:
@@ -243,6 +244,10 @@ def setUpTestData(cls):
can_write=False)
#TODO: Add organizations to groups
+ redCross = Organization.objects.create(
+ name = "CruzRoja",
+ description = "Red Cross"
+ )
cls.u4.groups.set([cls.g2])
cls.u5.groups.set([cls.g1, cls.g3])
From bf0aed7e833b606b63be2300a6c824f4e9dd884e Mon Sep 17 00:00:00 2001
From: sophiaashraf
Date: Tue, 18 Feb 2025 16:20:03 -0800
Subject: [PATCH 04/20] stash merge thing
sadkjnvlderinjegra
---
templates/login/organization_create.html | 3 +--
templates/login/organization_detail.html | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/templates/login/organization_create.html b/templates/login/organization_create.html
index 52543246..ca2cadbb 100644
--- a/templates/login/organization_create.html
+++ b/templates/login/organization_create.html
@@ -67,5 +67,4 @@ {% trans "Organization Details" %}
-
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/templates/login/organization_detail.html b/templates/login/organization_detail.html
index 4b2aad22..10b264f4 100644
--- a/templates/login/organization_detail.html
+++ b/templates/login/organization_detail.html
@@ -62,5 +62,4 @@ {% trans "Ambulances in this Organization" %}
-
-{% endblock %}
\ No newline at end of file
+{% endblock %}
From fad11bf1b8703064a6486829dc789286ef5ecb3a Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Tue, 18 Feb 2025 16:35:14 -0800
Subject: [PATCH 05/20] comment adds
---
login/models.py | 1 +
login/tests/setup_data.py | 2 +-
login/views.py | 3 ++-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/login/models.py b/login/models.py
index 52a87524..bd73e149 100644
--- a/login/models.py
+++ b/login/models.py
@@ -57,6 +57,7 @@ def is_guest(user):
class Organization(models.Model):
name = models.CharField(_('name'), max_length=100, unique=True)
description = models.CharField(_('description'), max_length=100, blank=True)
+ #symmetrical relationships
users = models.ManyToManyField(User)
ambulances = models.ManyToManyField('ambulance.Ambulance')
equipment_set = models.ManyToManyField('equipment.EquipmentSet')
diff --git a/login/tests/setup_data.py b/login/tests/setup_data.py
index 8b15ee67..32c01a10 100644
--- a/login/tests/setup_data.py
+++ b/login/tests/setup_data.py
@@ -244,7 +244,7 @@ def setUpTestData(cls):
can_write=False)
#TODO: Add organizations to groups
- redCross = Organization.objects.create(
+ cls.o1 = Organization.objects.create(
name = "CruzRoja",
description = "Red Cross"
)
diff --git a/login/views.py b/login/views.py
index 03af28ec..a41ae437 100644
--- a/login/views.py
+++ b/login/views.py
@@ -303,8 +303,9 @@ def get_context_data(self, **kwargs):
context['ambulance_list'] = self.object.userambulancepermission_set.all()
context['hospital_list'] = self.object.userhospitalpermission_set.all()
- # retrieve groups and add to context
+ # TODO: retrieve organizations user is in and add to context
context['group_list'] = self.object.groups.all()
+ context['org_list'] = self.object.organizations.all()
return context
From 862dff325795ab9134cd6df244b186c4a8204929 Mon Sep 17 00:00:00 2001
From: sophiaashraf
Date: Tue, 18 Feb 2025 16:47:32 -0800
Subject: [PATCH 06/20] Dockerfile
---
Dockerfile | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index db8ef972..769969ba 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,14 +10,11 @@ RUN set -x && \
apt-get install -y apt-utils && \
apt-get install -y dumb-init git gettext \
gdal-bin libgdal-dev python3-gdal \
- postgresql-client mosquitto-clients \
- rsync
+ postgresql-client mosquitto-clients
# Install node
-#For windows
-#RUN apt-get install -y nodejs npm
-
-#For mac
+#RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
+ #apt-get install -y nodejs npm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
RUN nvm install node
@@ -49,17 +46,21 @@ RUN pip install .
WORKDIR $APP_HOME
-# create application directories
+# link migration directories into persistent volume
RUN set -x && \
mkdir -p /etc/emstrack/migrations && \
mkdir -p /etc/emstrack/migrations/ambulance && \
mkdir ambulance && \
+ ln -s /etc/emstrack/migrations/ambulance $APP_HOME/ambulance/migrations && \
mkdir -p /etc/emstrack/migrations/login && \
mkdir login && \
+ ln -s /etc/emstrack/migrations/login $APP_HOME/login/migrations && \
mkdir -p /etc/emstrack/migrations/hospital && \
mkdir hospital && \
+ ln -s /etc/emstrack/migrations/hospital $APP_HOME/hospital/migrations && \
mkdir -p /etc/emstrack/migrations/equipment && \
mkdir equipment && \
+ ln -s /etc/emstrack/migrations/equipment $APP_HOME/equipment/migrations && \
# mosquitto directories
mkdir -p /mosquitto/data && \
touch /mosquitto/data/passwd && \
@@ -73,15 +74,6 @@ RUN set -x && \
# Clone application
COPY . .
-# link migration directories into persistent volume
-# since fall of 2024 copy fails if links are made before
-RUN set -x && \
- ln -s /etc/emstrack/migrations/ambulance $APP_HOME/ambulance/migrations && \
- ln -s /etc/emstrack/migrations/login $APP_HOME/login/migrations && \
- ln -s /etc/emstrack/migrations/hospital $APP_HOME/hospital/migrations && \
- ln -s /etc/emstrack/migrations/equipment $APP_HOME/equipment/migrations && \
- ln -s /etc/emstrack/log $APP_HOME/log
-
# Init scripts
COPY scripts/. $SCRIPT_HOME
RUN chmod +x $SCRIPT_HOME/emstrack-*.sh
From 2ed03593ed33363b7cd7e06af43f09085b6d18ff Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Tue, 18 Feb 2025 18:05:02 -0800
Subject: [PATCH 07/20] Add list model
---
login/views.py | 3 ++-
templates/login/user_detail.html | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/login/views.py b/login/views.py
index a41ae437..de264a6e 100644
--- a/login/views.py
+++ b/login/views.py
@@ -305,7 +305,8 @@ def get_context_data(self, **kwargs):
# TODO: retrieve organizations user is in and add to context
context['group_list'] = self.object.groups.all()
- context['org_list'] = self.object.organizations.all()
+ # Autogenerated fetch method name
+ context['org_list'] = self.object.organization_set.all()
return context
diff --git a/templates/login/user_detail.html b/templates/login/user_detail.html
index 179ce21a..6e643d8e 100644
--- a/templates/login/user_detail.html
+++ b/templates/login/user_detail.html
@@ -96,6 +96,37 @@ {% trans "Groups" %}:
{% endif %}
+ {% trans "Organizations" %}:
+
+ {% if org_list %}
+
+
+
+
+ {% trans "Name" %} |
+ {% trans "Description" %} |
+
+
+
+ {% for org in org_list %}
+
+
+ {{ org.name }}
+ |
+
+ {{ org.description }}
+ |
+
+ {% endfor %}
+
+
+
+ {% else %}
+
+ {% trans "This user does not belongs to any organization yet." %}
+
+ {% endif %}
+
From 558cfe2907fd6bf15d0cf74bfca77c9ce626e962 Mon Sep 17 00:00:00 2001
From: sophiaashraf
Date: Tue, 25 Feb 2025 15:12:29 -0800
Subject: [PATCH 08/20] Update Dockerfile
---
Dockerfile | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 769969ba..74793ac8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# Using ubuntu as a base image
-FROM python:3.7
+FROM python:3.11
# Getting rid of debconf messages
ARG DEBIAN_FRONTEND=noninteractive
@@ -13,10 +13,23 @@ RUN set -x && \
postgresql-client mosquitto-clients
# Install node
+#ENV NODE_VERSION 23.8.0
+
#RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
- #apt-get install -y nodejs npm
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
-RUN nvm install node
+RUN apt-get install -y nodejs npm
+
+#RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
+#&& apt-get install -y npm
+
+#ENV NVM_DIR=/root/.nvm
+#RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
+#RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
+#RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
+#ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
+#RUN node --version
+#RUN npm --version
+
+
# Build variables
ARG BUILD_APP_HOME=/app
From ab7bb15d8b45cbddb8201110b4a998b3a067f2be Mon Sep 17 00:00:00 2001
From: sophiaashraf <103149287+sophiaashraf@users.noreply.github.com>
Date: Tue, 25 Feb 2025 16:24:39 -0800
Subject: [PATCH 09/20] Update Dockerfile to 3.8
---
Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 769969ba..cb69b7a0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# Using ubuntu as a base image
-FROM python:3.7
+FROM python:3.8
# Getting rid of debconf messages
ARG DEBIAN_FRONTEND=noninteractive
From 9f4c2d809a7e20e9f84d899b37aff230174bb9d9 Mon Sep 17 00:00:00 2001
From: sophiaashraf <103149287+sophiaashraf@users.noreply.github.com>
Date: Tue, 25 Feb 2025 16:27:13 -0800
Subject: [PATCH 10/20] Update Dockerfile
---
Dockerfile | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index cb69b7a0..e563b571 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,13 +10,16 @@ RUN set -x && \
apt-get install -y apt-utils && \
apt-get install -y dumb-init git gettext \
gdal-bin libgdal-dev python3-gdal \
- postgresql-client mosquitto-clients
+ postgresql-client mosquitto-clients \
+ rsync
# Install node
-#RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
- #apt-get install -y nodejs npm
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
-RUN nvm install node
+RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
+ apt-get install -y nodejs
+
+#RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
+#RUN nvm install node
+
# Build variables
ARG BUILD_APP_HOME=/app
@@ -46,21 +49,17 @@ RUN pip install .
WORKDIR $APP_HOME
-# link migration directories into persistent volume
+# create application directories
RUN set -x && \
mkdir -p /etc/emstrack/migrations && \
mkdir -p /etc/emstrack/migrations/ambulance && \
mkdir ambulance && \
- ln -s /etc/emstrack/migrations/ambulance $APP_HOME/ambulance/migrations && \
mkdir -p /etc/emstrack/migrations/login && \
mkdir login && \
- ln -s /etc/emstrack/migrations/login $APP_HOME/login/migrations && \
mkdir -p /etc/emstrack/migrations/hospital && \
mkdir hospital && \
- ln -s /etc/emstrack/migrations/hospital $APP_HOME/hospital/migrations && \
mkdir -p /etc/emstrack/migrations/equipment && \
mkdir equipment && \
- ln -s /etc/emstrack/migrations/equipment $APP_HOME/equipment/migrations && \
# mosquitto directories
mkdir -p /mosquitto/data && \
touch /mosquitto/data/passwd && \
@@ -74,6 +73,15 @@ RUN set -x && \
# Clone application
COPY . .
+# link migration directories into persistent volume
+# since fall of 2024 copy fails if links are made before
+RUN set -x && \
+ ln -s /etc/emstrack/migrations/ambulance $APP_HOME/ambulance/migrations && \
+ ln -s /etc/emstrack/migrations/login $APP_HOME/login/migrations && \
+ ln -s /etc/emstrack/migrations/hospital $APP_HOME/hospital/migrations && \
+ ln -s /etc/emstrack/migrations/equipment $APP_HOME/equipment/migrations && \
+ ln -s /etc/emstrack/log $APP_HOME/log
+
# Init scripts
COPY scripts/. $SCRIPT_HOME
RUN chmod +x $SCRIPT_HOME/emstrack-*.sh
From 6e9968b65f75ea8e7a60323794ae4bf83c9a2e77 Mon Sep 17 00:00:00 2001
From: sophiaashraf
Date: Tue, 25 Feb 2025 16:41:18 -0800
Subject: [PATCH 11/20] added group list
---
login/views.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/login/views.py b/login/views.py
index a41ae437..f61ca494 100644
--- a/login/views.py
+++ b/login/views.py
@@ -168,6 +168,7 @@ def get_context_data(self, **kwargs):
# retrieve users and add to context
# context['user_list'] = self.object.user_set.all()
+ context['group_list'] = self.object.groups.all()
return context
From 9641b5ed5cc54179d2f09715e749f4365fdc3478 Mon Sep 17 00:00:00 2001
From: sophiaashraf
Date: Tue, 25 Feb 2025 16:48:36 -0800
Subject: [PATCH 12/20] added table & header for groups
---
templates/login/organization_detail.html | 31 +++++++++++++++++++-----
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/templates/login/organization_detail.html b/templates/login/organization_detail.html
index 10b264f4..9318b992 100644
--- a/templates/login/organization_detail.html
+++ b/templates/login/organization_detail.html
@@ -11,7 +11,6 @@
-
{% trans "Organizations" %}
-
- {{ organization.name }}
@@ -19,22 +18,18 @@
-
{% trans "Organization Details" %}
{% trans "Name" %}:
{{ organization.name }}
-
{% trans "Description" %}:
{{ organization.description|default:"{% trans 'No description provided.' %}"|safe }}
-
-
{% if organization.permissions.all %}
{% trans "Organization Permissions" %}
@@ -47,7 +42,6 @@ {% trans "Organization Permissions" %}
{% trans "No permissions assigned." %}
{% endif %}
-
{% if organization.ambulances.all %}
{% trans "Ambulances in this Organization" %}
@@ -59,6 +53,31 @@ {% trans "Ambulances in this Organization" %}
{% trans "Ambulances in this Organization" %}
{% trans "No ambulances assigned." %}
{% endif %}
+
+
+ {% trans "Groups in this Organization" %}
+
+ {% if group_list %}
+
+
+
+ {% trans "Name" %} |
+
+
+
+ {% for group in group_list %}
+
+
+ {{ group.name }}
+ |
+
+ {% endfor %}
+
+
+ {% else %}
+ {% trans "No groups assigned." %}
+ {% endif %}
+
From 6de3ceb422b6ec949e42289d72f67dc1718129b3 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Wed, 5 Mar 2025 19:20:28 -0800
Subject: [PATCH 13/20] settings and slight bug fix
---
emstrack/settings.py | 2 +-
login/views.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/emstrack/settings.py b/emstrack/settings.py
index 4746c4d0..20844d1d 100644
--- a/emstrack/settings.py
+++ b/emstrack/settings.py
@@ -43,7 +43,7 @@
}
# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = env.bool('DJANGO_DEBUG', default=False)
+DEBUG = env.bool('DJANGO_DEBUG', default=True)
allowed_hosts = env.str('DJANGO_HOSTNAMES', default="*")
if allowed_hosts == "*":
ALLOWED_HOSTS = ["*"]
diff --git a/login/views.py b/login/views.py
index 62ee677c..d59139d6 100644
--- a/login/views.py
+++ b/login/views.py
@@ -168,7 +168,7 @@ def get_context_data(self, **kwargs):
# retrieve users and add to context
# context['user_list'] = self.object.user_set.all()
- context['group_list'] = self.object.groups.all()
+ context['group_list'] = Group.objects.all()
return context
From efa35960eee01184cd979d76b1e58e00e08e26c8 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Wed, 5 Mar 2025 22:41:10 -0800
Subject: [PATCH 14/20] nullkey fix
---
login/migrations/0006_auto_20241120_0110.py | 2 +-
login/models.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/login/migrations/0006_auto_20241120_0110.py b/login/migrations/0006_auto_20241120_0110.py
index c766468c..5156b769 100644
--- a/login/migrations/0006_auto_20241120_0110.py
+++ b/login/migrations/0006_auto_20241120_0110.py
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
model_name='groupprofile',
name='organization',
# Remove default to make "required field"
- field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='login.Organization', verbose_name='organization'),
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='login.Organization', verbose_name='organization'),
),
]
\ No newline at end of file
diff --git a/login/models.py b/login/models.py
index bd73e149..63688d7b 100644
--- a/login/models.py
+++ b/login/models.py
@@ -120,7 +120,7 @@ def can_sms_notifications():
# GroupProfile
class GroupProfile(ClearPermissionCacheMixin, models.Model):
- organization = models.ForeignKey(Organization, on_delete = models.CASCADE, verbose_name = _('organization'), null = False)
+ organization = models.ForeignKey(Organization, on_delete = models.CASCADE, verbose_name = _('organization'), null = True)
group = models.OneToOneField(
Group, on_delete=models.CASCADE, verbose_name=_('group')
From fa9f902ef1484a915e78ba4384493edfbf30ceaa Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Thu, 6 Mar 2025 00:38:04 -0800
Subject: [PATCH 15/20] Added organizations to group detail/list.
---
templates/login/group_detail.html | 5 +++++
templates/login/group_list.html | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/templates/login/group_detail.html b/templates/login/group_detail.html
index a9d8bce8..bfb92979 100644
--- a/templates/login/group_detail.html
+++ b/templates/login/group_detail.html
@@ -30,6 +30,11 @@ {% trans "Details" %}:
{{ group.groupprofile.description }}
+
+ {% trans "Organization" %}:
+ {{ group.groupprofile.organization }}
+
+
{% trans "Priority" %}:
{{ group.groupprofile.priority }}
diff --git a/templates/login/group_list.html b/templates/login/group_list.html
index 66cc1f97..71f45bb1 100644
--- a/templates/login/group_list.html
+++ b/templates/login/group_list.html
@@ -34,6 +34,7 @@
{% trans "Groups" %}
{% trans "Name" %} |
{% trans "Description" %} |
+ {% trans "Organization" %} |
{% trans "Priority" %} |
{% trans "SMS Notifications" %} |
{% trans "Number of Users" %} |
@@ -48,6 +49,9 @@ {% trans "Groups" %}
{{ group.groupprofile.description }}
|
+
+ {{ group.groupprofile.organization }}
+ |
{{ group.groupprofile.priority }}
|
From 088abbd9edc3b146f9ff794df8d73d7d00108d70 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Thu, 6 Mar 2025 00:40:15 -0800
Subject: [PATCH 16/20] Added filtering for groups in organization_detail.
---
login/views.py | 3 ++-
templates/login/organization_detail.html | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/login/views.py b/login/views.py
index d59139d6..eb32ccc2 100644
--- a/login/views.py
+++ b/login/views.py
@@ -152,6 +152,7 @@ class OrganizationAdminListView(PaginationViewMixin, ListView):
template_name = 'login/organization_list.html'
ordering = 'name'
+#https://docs.djangoproject.com/en/5.1/topics/db/queries/#lookups-that-span-relationships
class OrganizationAdminDetailView(DetailView):
model = Organization
template_name = 'login/organization_detail.html'
@@ -168,7 +169,7 @@ def get_context_data(self, **kwargs):
# retrieve users and add to context
# context['user_list'] = self.object.user_set.all()
- context['group_list'] = Group.objects.all()
+ context['group_list'] = GroupProfile.objects.filter(organization = self.object)
return context
diff --git a/templates/login/organization_detail.html b/templates/login/organization_detail.html
index 9318b992..b3ec16bd 100644
--- a/templates/login/organization_detail.html
+++ b/templates/login/organization_detail.html
@@ -65,10 +65,10 @@ {% trans "Groups in this Organization" %}
- {% for group in group_list %}
+ {% for group_profile in group_list %}
- {{ group.name }}
+ {{ group_profile.group.name }}
|
{% endfor %}
From ba16f9b616903e4fcd04908f2fd6e13d4f5d82c4 Mon Sep 17 00:00:00 2001
From: sophiaashraf
Date: Mon, 10 Mar 2025 15:03:41 -0700
Subject: [PATCH 17/20] ignore
---
---
login/views.py | 4 ++--
templates/login/group_detail.html | 5 ++---
templates/login/group_form.html | 23 ++++++++++++-----------
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/login/views.py b/login/views.py
index eb32ccc2..58338d0e 100644
--- a/login/views.py
+++ b/login/views.py
@@ -152,7 +152,6 @@ class OrganizationAdminListView(PaginationViewMixin, ListView):
template_name = 'login/organization_list.html'
ordering = 'name'
-#https://docs.djangoproject.com/en/5.1/topics/db/queries/#lookups-that-span-relationships
class OrganizationAdminDetailView(DetailView):
model = Organization
template_name = 'login/organization_detail.html'
@@ -169,7 +168,8 @@ def get_context_data(self, **kwargs):
# retrieve users and add to context
# context['user_list'] = self.object.user_set.all()
- context['group_list'] = GroupProfile.objects.filter(organization = self.object)
+ #context['group_list'] = Group.objects.filter(groupprofile__organization=self.object)
+ context['group_list'] = G.all()
return context
diff --git a/templates/login/group_detail.html b/templates/login/group_detail.html
index bfb92979..5b7eaca8 100644
--- a/templates/login/group_detail.html
+++ b/templates/login/group_detail.html
@@ -29,12 +29,11 @@ {% trans "Details" %}:
{% trans "Description" %}:
{{ group.groupprofile.description }}
-
{% trans "Organization" %}:
- {{ group.groupprofile.organization }}
+ {{ group.groupprofile.organization.name|default:"Uncategorized" }}
-
+
{% trans "Priority" %}:
{{ group.groupprofile.priority }}
diff --git a/templates/login/group_form.html b/templates/login/group_form.html
index 02b403ba..79a97793 100644
--- a/templates/login/group_form.html
+++ b/templates/login/group_form.html
@@ -1,13 +1,13 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
+{% load formset_tags %} {# Added this here to keep all template tags together at the top for better readability #}
{% block head %}
{{ form.media }}
{% endblock %}
{% block content %}
-{% load formset_tags %}
@@ -81,9 +81,7 @@
{% trans "Permissions" %}:
-
+
-
+
-
+
{% endfor %}
From 6bc138f45e8e14840ccb67159c8e4a55f130f06c Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Fri, 21 Mar 2025 23:45:06 -0700
Subject: [PATCH 18/20] Added update page for Organizations
---
login/forms.py | 11 ++++++++++
login/models.py | 4 ++--
login/views.py | 12 ++++++++---
templates/login/organization_detail.html | 2 +-
templates/login/organization_form.html | 26 ++++++++++++++++++++++++
5 files changed, 49 insertions(+), 6 deletions(-)
create mode 100644 templates/login/organization_form.html
diff --git a/login/forms.py b/login/forms.py
index fa3c67df..116154b6 100644
--- a/login/forms.py
+++ b/login/forms.py
@@ -275,6 +275,17 @@ class Media(object):
# Other form media here
)
+class OrganizationAdminUpdateForm(forms.ModelForm):
+ class Meta:
+ model = Organization
+ fields = ['name', 'description']
+
+ def __init__(self, *args, **kwargs):
+ # call super
+ super().__init__(*args, **kwargs)
+
+ # disable name
+ self.fields['name'].disabled = True
class GroupProfileAdminForm(forms.ModelForm):
class Meta:
diff --git a/login/models.py b/login/models.py
index 63688d7b..a825a7ea 100644
--- a/login/models.py
+++ b/login/models.py
@@ -236,8 +236,8 @@ def __str__(self):
self.can_write,
)
#OrganizationAmbulancePermission
-class OrganizationAmbulancePermission(ClearPermissionCacheMixin, Permission):
- pass
+#class OrganizationAmbulancePermission(ClearPermissionCacheMixin, Permission):
+# pass
# random string
def random_string_generator(
diff --git a/login/views.py b/login/views.py
index eb32ccc2..f514d34b 100644
--- a/login/views.py
+++ b/login/views.py
@@ -18,7 +18,7 @@
from django.views.generic import ListView, DetailView
from django.views.generic.base import View, TemplateView
from django.views.generic.detail import BaseDetailView
-from django.views.generic.edit import FormView, CreateView
+from django.views.generic.edit import FormView, CreateView, UpdateView
from drf_extra_fields.geo_fields import PointField
from extra_views import (
InlineFormSetFactory,
@@ -184,9 +184,15 @@ def get_success_message(self, cleaned_data):
def get_success_url(self):
return self.object.get_absolute_url()
-class OrganizationAdminUpdateView(SuccessMessageWithInlinesMixin, UpdateWithInlinesView):
+#class OrganizationAdminInline(InlineFormSetFactory):
+# model = Organization
+ # form_class = Orga
+
+#TODO: Convert to UpdateWithInlinesView, remove UpdateView import
+class OrganizationAdminUpdateView(SuccessMessageMixin, UpdateView):
model = Organization
- #template_name = 'login/group_form.html'
+ fields = ['name', 'description']
+ template_name = 'login/organization_form.html'
#form_class = GroupAdminUpdateForm
#inlines = [
# GroupProfileAdminInline,
diff --git a/templates/login/organization_detail.html b/templates/login/organization_detail.html
index b3ec16bd..0a1c7a2b 100644
--- a/templates/login/organization_detail.html
+++ b/templates/login/organization_detail.html
@@ -27,7 +27,7 @@ {% trans "Organization Details" %}
{% trans "Description" %}:
- {{ organization.description|default:"{% trans 'No description provided.' %}"|safe }}
+ {{ organization.description|default:"No description provided"|safe }}
{% if organization.permissions.all %}
diff --git a/templates/login/organization_form.html b/templates/login/organization_form.html
new file mode 100644
index 00000000..338509cb
--- /dev/null
+++ b/templates/login/organization_form.html
@@ -0,0 +1,26 @@
+{% extends "base.html" %}
+{% load static %}
+{% load i18n %}
+
+{% block content %}
+
+
+
+
+
+
{% trans "Organization" %}
+
+
+
+
+
+
+{% endblock %}
From 90fdbe03059faddd066822ee71f6f1b406461498 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Fri, 21 Mar 2025 23:56:58 -0700
Subject: [PATCH 19/20] Revert "ignore"
This reverts commit ba16f9b616903e4fcd04908f2fd6e13d4f5d82c4.
also adds a comment I forgot to save
---
login/forms.py | 1 +
login/views.py | 4 ++--
templates/login/group_detail.html | 5 +++--
templates/login/group_form.html | 23 +++++++++++------------
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/login/forms.py b/login/forms.py
index 116154b6..de8009b0 100644
--- a/login/forms.py
+++ b/login/forms.py
@@ -275,6 +275,7 @@ class Media(object):
# Other form media here
)
+# Currently unused, but probably needed in future.
class OrganizationAdminUpdateForm(forms.ModelForm):
class Meta:
model = Organization
diff --git a/login/views.py b/login/views.py
index 9711727e..f514d34b 100644
--- a/login/views.py
+++ b/login/views.py
@@ -152,6 +152,7 @@ class OrganizationAdminListView(PaginationViewMixin, ListView):
template_name = 'login/organization_list.html'
ordering = 'name'
+#https://docs.djangoproject.com/en/5.1/topics/db/queries/#lookups-that-span-relationships
class OrganizationAdminDetailView(DetailView):
model = Organization
template_name = 'login/organization_detail.html'
@@ -168,8 +169,7 @@ def get_context_data(self, **kwargs):
# retrieve users and add to context
# context['user_list'] = self.object.user_set.all()
- #context['group_list'] = Group.objects.filter(groupprofile__organization=self.object)
- context['group_list'] = G.all()
+ context['group_list'] = GroupProfile.objects.filter(organization = self.object)
return context
diff --git a/templates/login/group_detail.html b/templates/login/group_detail.html
index 5b7eaca8..bfb92979 100644
--- a/templates/login/group_detail.html
+++ b/templates/login/group_detail.html
@@ -29,11 +29,12 @@ {% trans "Details" %}:
{% trans "Description" %}:
{{ group.groupprofile.description }}
+
{% trans "Organization" %}:
- {{ group.groupprofile.organization.name|default:"Uncategorized" }}
+ {{ group.groupprofile.organization }}
-
+
{% trans "Priority" %}:
{{ group.groupprofile.priority }}
diff --git a/templates/login/group_form.html b/templates/login/group_form.html
index 79a97793..02b403ba 100644
--- a/templates/login/group_form.html
+++ b/templates/login/group_form.html
@@ -1,13 +1,13 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
-{% load formset_tags %} {# Added this here to keep all template tags together at the top for better readability #}
{% block head %}
{{ form.media }}
{% endblock %}
{% block content %}
+{% load formset_tags %}
@@ -81,7 +81,9 @@
{% trans "Permissions" %}:
-
+
-
+
-
-
+ });
{% endfor %}
From 20754b3af88b4f8a3a6e5dc90390546f52e3bb64 Mon Sep 17 00:00:00 2001
From: Eric Hu
Date: Sat, 22 Mar 2025 00:14:29 -0700
Subject: [PATCH 20/20] Added link to group_detail organization field.
---
templates/login/group_detail.html | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/templates/login/group_detail.html b/templates/login/group_detail.html
index bfb92979..eefbdbbc 100644
--- a/templates/login/group_detail.html
+++ b/templates/login/group_detail.html
@@ -32,7 +32,12 @@ {% trans "Details" %}:
{% trans "Organization" %}:
- {{ group.groupprofile.organization }}
+ {% if group.groupprofile.organization %}
+ {{ group.groupprofile.organization }}
+ {% else %}
+ {{ group.groupprofile.organization }}
+ {% endif %}
+