From a5a667aff80c7ab3e220e8f1e1a3adb09576d96c Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Tue, 19 Nov 2024 16:23:10 +0200 Subject: [PATCH 1/2] Resolves #879 --- alyx/alyx/__init__.py | 2 +- alyx/jobs/admin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/alyx/alyx/__init__.py b/alyx/alyx/__init__.py index 82a1aec7..90db8dcc 100644 --- a/alyx/alyx/__init__.py +++ b/alyx/alyx/__init__.py @@ -1 +1 @@ -VERSION = __version__ = '3.1.0' +VERSION = __version__ = '3.1.1' diff --git a/alyx/jobs/admin.py b/alyx/jobs/admin.py index 7c2dad0b..0114cea4 100644 --- a/alyx/jobs/admin.py +++ b/alyx/jobs/admin.py @@ -29,7 +29,7 @@ def has_change_permission(self, request, obj=None): if obj: if obj.session: # Check if session user or member of the same lab - is_session_user = obj.session.users.users.contains(request.user) + is_session_user = obj.session.users.contains(request.user) return is_session_user or obj.session.lab.name in request.user.lab else: # Check if user is member of the lab associated with the task repository From be80622db99d63cff6f9aedb734b7a2b799ec261 Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Tue, 19 Nov 2024 16:24:09 +0200 Subject: [PATCH 2/2] Resolves #878 --- alyx/actions/admin.py | 8 +------- .../0026_alter_surgery_implant_weight.py | 19 +++++++++++++++++++ alyx/actions/models.py | 2 +- alyx/subjects/admin.py | 4 ++-- 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 alyx/actions/migrations/0026_alter_surgery_implant_weight.py diff --git a/alyx/actions/admin.py b/alyx/actions/admin.py index 8d08f5ef..ab69393c 100644 --- a/alyx/actions/admin.py +++ b/alyx/actions/admin.py @@ -416,14 +416,8 @@ class WaterTypeAdmin(BaseActionAdmin): list_display_links = ('name',) -class SurgeryActionForm(BaseActionForm): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.fields['implant_weight'].required = True - - class SurgeryAdmin(BaseActionAdmin): - form = SurgeryActionForm + form = BaseActionForm list_display = ['subject_l', 'date', 'users_l', 'procedures_l', 'narrative', 'projects', 'implant_weight'] list_select_related = ('subject',) diff --git a/alyx/actions/migrations/0026_alter_surgery_implant_weight.py b/alyx/actions/migrations/0026_alter_surgery_implant_weight.py new file mode 100644 index 00000000..8cb40635 --- /dev/null +++ b/alyx/actions/migrations/0026_alter_surgery_implant_weight.py @@ -0,0 +1,19 @@ +# Generated by Django 5.1.2 on 2024-11-19 14:14 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('actions', '0025_move_implant_weight'), + ] + + operations = [ + migrations.AlterField( + model_name='surgery', + name='implant_weight', + field=models.FloatField(help_text='Implant weight in grams', validators=[django.core.validators.MinValueValidator(0)]), + ), + ] diff --git a/alyx/actions/models.py b/alyx/actions/models.py index 488cfb54..8c08e959 100644 --- a/alyx/actions/models.py +++ b/alyx/actions/models.py @@ -203,7 +203,7 @@ class Surgery(BaseAction): default=_default_surgery_location, help_text="The physical location at which the surgery was " "performed") - implant_weight = models.FloatField(null=False, blank=True, validators=[MinValueValidator(0)], + implant_weight = models.FloatField(null=False, blank=False, validators=[MinValueValidator(0)], help_text="Implant weight in grams") class Meta: diff --git a/alyx/subjects/admin.py b/alyx/subjects/admin.py index 5c736786..e1ac3b28 100755 --- a/alyx/subjects/admin.py +++ b/alyx/subjects/admin.py @@ -20,7 +20,7 @@ ) from actions.models import ( Surgery, Session, OtherAction, WaterAdministration, WaterRestriction, Weighing) -from actions.admin import SurgeryActionForm +from actions.admin import BaseActionForm from misc.models import LabMember, Housing from misc.admin import NoteInline @@ -236,7 +236,7 @@ def has_add_permission(self, request, obj=None): class AddSurgeryInline(SurgeryInline): - form = SurgeryActionForm + form = BaseActionForm readonly_fields = () show_change_link = False verbose_name = "New surgery"