Skip to content

Commit

Permalink
fixed participant edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
bbonf committed Dec 18, 2023
1 parent 6530ec4 commit eb42159
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
8 changes: 6 additions & 2 deletions lab/participants/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from cdh.core.forms import BootstrapCheckboxInput, TemplatedModelForm
from cdh.core.forms import (
BootstrapCheckboxInput,
BootstrapRadioSelect,
TemplatedModelForm,
)
from django import forms

from .models import ExtraData, ParticipantData
Expand All @@ -25,7 +29,7 @@ class Meta:
"name": forms.TextInput,
"phonenumber": forms.TextInput,
"phonenumber_alt": forms.TextInput,
"sex": ParticipantSexWidget,
"sex": BootstrapRadioSelect,
"email_subscription": BootstrapCheckboxInput,
"english_contact": BootstrapCheckboxInput,
}
Expand Down
4 changes: 2 additions & 2 deletions lab/participants/models/participantdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

from utils.models import EncryptedManager

from .enums import BirthWeight, PregnancyDuration, WhichParent
from .enums import BirthWeight, PregnancyDuration, Sex, WhichParent
from .language import Language


class ParticipantData(models.Model):
objects = EncryptedManager()

name = e_fields.EncryptedTextField(_("participant:attribute:name"), blank=True, null=True)
sex = e_fields.EncryptedTextField(_("participant:attribute:sex"), blank=True, null=True)
sex = e_fields.EncryptedTextField(_("participant:attribute:sex"), null=True, choices=Sex.choices)
birth_date = e_fields.EncryptedDateField(_("participant:attribute:birth_date"), blank=True, null=True)

birth_weight = e_fields.EncryptedCharField(
Expand Down
4 changes: 2 additions & 2 deletions lab/participants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from . import graphs
from .forms import ExtraDataForm, ParticipantForm
from .models import ExtraData, Participant
from .models import ExtraData, Participant, ParticipantData


class ParticipantsHomeView(RandomLeaderMixin, generic.ListView):
Expand Down Expand Up @@ -43,7 +43,7 @@ def get_context_data(self, *args, **kwargs):


class ParticipantUpdateView(RandomLeaderMixin, SuccessMessageMixin, generic.UpdateView):
model = Participant
model = ParticipantData
template_name = "participants/edit.html"
success_message = _("participants:messages:updated_participant")
form_class = ParticipantForm
Expand Down
25 changes: 0 additions & 25 deletions lab/participants/widgets.py

This file was deleted.

0 comments on commit eb42159

Please sign in to comment.