Skip to content

Commit dc99b46

Browse files
committed
fix tests when we can't get current object from request
1 parent cdf1e7f commit dc99b46

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

alyx/actions/admin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,12 @@ class Meta:
348348
class WaterRestrictionAdmin(BaseActionAdmin):
349349
def formfield_for_foreignkey(self, db_field, request, **kwargs):
350350
if db_field.name == 'subject':
351-
object_id = request.resolver_match.kwargs.get('object_id')
352-
obj = self.get_object(request, object_id) if object_id else None
351+
obj = None
353352
kwargs['queryset'] = Subject.objects.filter(cull__isnull=True).order_by('nickname')
353+
# here if the form is of an existing water restriction, get the subject
354+
if request.resolver_match is not None:
355+
object_id = request.resolver_match.kwargs.get('object_id')
356+
obj = self.get_object(request, object_id) if object_id else None
354357
if obj is not None:
355358
kwargs['queryset'] = (kwargs['queryset'] | Subject.objects.filter(pk=obj.subject.pk)).order_by('nickname')
356359
kwargs['initial'] = obj.subject

deploy/docker-compose-postgres-gunicorn.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
container_name: alyx_apache
55
ports:
66
- "8000:8000"
7-
env_file: ../alyx/alyx/.env_local
7+
env_file: ../alyx/alyx/.env
88
command: >
99
bash -c "python /var/www/alyx/alyx/manage.py collectstatic --noinput &&
1010
gunicorn --workers 2 -b 0.0.0.0:8000 alyx.gunicorn_wsgi:application"
@@ -19,7 +19,7 @@ services:
1919
postgres:
2020
image: postgres:17
2121
container_name: alyx_postgres
22-
env_file: ../alyx/alyx/.env_local
22+
env_file: ../alyx/alyx/.env
2323
volumes:
2424
- alyx_postgres:/var/lib/postgresql/data
2525
expose:

deploy/docker-compose-postgres.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
postgres:
33
image: postgres:17
44
container_name: alyx_postgres
5-
env_file: ../alyx/alyx/.env
5+
env_file: ../alyx/alyx/.env_prod
66
volumes:
77
- alyx_postgres:/var/lib/postgresql/data
88
ports:

0 commit comments

Comments
 (0)