Ejemplo n.º 1
0
class ContactRecordForm(forms.ModelForm):
    """Form to add ContactRecords on participants.

    Sometimes auto-specifies participant and current user"""

    participant = selectable.AutoCompleteSelectField(
        label='Type the name of the participant:',
        lookup_class=UserLookup,
        required=True,
    )
    added_by = selectable.AutoCompleteSelectField(
        label='Who is adding this record?',
        lookup_class=UserLookup,
        required=True,
    )

    class Meta:
        model = ContactRecord
        exclude = []

    def __init__(self, *args, **kwargs):
        super(ContactRecordForm, self).__init__(*args, **kwargs)

        meta = getattr(self, 'Meta', None)
        exclude = getattr(meta, 'exclude', [])

        for field_name in exclude:
            if field_name in self.fields:
                del self.fields[field_name]
Ejemplo n.º 2
0
class SmartTagForm(forms.Form):
    RESOURCE_CHOICES = (
        ('study', 'Study'),
        ('endpoint', 'Endpoint'),
        ('visual', 'Visualization'),
        ('data_pivot', 'Data Pivot'),
    )
    resource = forms.ChoiceField(choices=RESOURCE_CHOICES)
    study = selectable.AutoCompleteSelectField(
        lookup_class=StudyLookup,
        help_text=
        "Type a few characters of the study name, then click to select.")
    endpoint = selectable.AutoCompleteSelectField(
        lookup_class=EndpointByAssessmentLookup,
        help_text=
        "Type a few characters of the endpoint name, then click to select.")
    visual = selectable.AutoCompleteSelectField(
        lookup_class=lookups.VisualLookup,
        help_text=
        "Type a few characters of the visual name, then click to select.")
    data_pivot = selectable.AutoCompleteSelectField(
        lookup_class=lookups.DataPivotLookup,
        help_text=
        "Type a few characters of the data-pivot name, then click to select.")

    def __init__(self, *args, **kwargs):
        assessment_id = kwargs.pop('assessment_id', -1)
        super().__init__(*args, **kwargs)
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            widget.attrs['class'] = 'span12'
            if hasattr(widget, 'update_query_parameters'):
                widget.update_query_parameters({'related': assessment_id})
                widget.attrs['class'] += " smartTagSearch"
Ejemplo n.º 3
0
class FruitForm(forms.Form):
    autocomplete = forms.CharField(
        label='Type the name of a fruit (AutoCompleteWidget)',
        widget=selectable.AutoCompleteWidget(FruitLookup),
        required=False,
    )
    newautocomplete = forms.CharField(
        label='Type the name of a fruit (AutoCompleteWidget which allows new items)',
        widget=selectable.AutoCompleteWidget(FruitLookup, allow_new=True),
        required=False,
    )
    combobox = forms.CharField(
        label='Type/select the name of a fruit (AutoComboboxWidget)',
        widget=selectable.AutoComboboxWidget(FruitLookup),
        required=False,
    )
    newcombobox = forms.CharField(
        label='Type/select the name of a fruit (AutoComboboxWidget which allows new items)',
        widget=selectable.AutoComboboxWidget(FruitLookup, allow_new=True),
        required=False,
    )
    # AutoCompleteSelectField (no new items)
    autocompleteselect = selectable.AutoCompleteSelectField(
        lookup_class=FruitLookup,
        label='Select a fruit (AutoCompleteField)',
        required=False,
    )
    # AutoCompleteSelectField (allows new items)
    newautocompleteselect = selectable.AutoCompleteSelectField(
        lookup_class=FruitLookup,
        allow_new=True,
        label='Select a fruit (AutoCompleteField which allows new items)',
        required=False,
    )
    # AutoComboboxSelectField (no new items)
    comboboxselect = selectable.AutoComboboxSelectField(
        lookup_class=FruitLookup,
        label='Select a fruit (AutoComboboxSelectField)',
        required=False,
    )
    # AutoComboboxSelectField (allows new items)
    newcomboboxselect = selectable.AutoComboboxSelectField(
        lookup_class=FruitLookup,
        allow_new=True,
        label='Select a fruit (AutoComboboxSelectField which allows new items)',
        required=False,
    )
    # AutoCompleteSelectMultipleField
    multiautocompleteselect = selectable.AutoCompleteSelectMultipleField(
        lookup_class=FruitLookup,
        label='Select a fruit (AutoCompleteSelectMultipleField)',
        required=False,
    )
    # AutoComboboxSelectMultipleField
    multicomboboxselect = selectable.AutoComboboxSelectMultipleField(
        lookup_class=FruitLookup,
        label='Select a fruit (AutoComboboxSelectMultipleField)',
        required=False,
    )
Ejemplo n.º 4
0
class MembershipAdminForm(forms.ModelForm):
    user = selectable.AutoCompleteSelectField(lookup_class=UserLookup)
    relates_to = selectable.AutoCompleteSelectField(
        lookup_class=MembershipLookup, required=False)

    class Meta(object):
        exclude = []
        model = Membership
Ejemplo n.º 5
0
class SmartTagForm(forms.Form):
    RESOURCE_CHOICES = (
        ('study', 'Study'),
        ('endpoint', 'Endpoint'),
        ('visual', 'Visualization'),
        ('data_pivot', 'Data Pivot'),
    )
    DISPLAY_TYPE_CHOICES = (
        ('popup', 'Popup'),
        ('inline', 'Inline'),
    )
    resource = forms.ChoiceField(choices=RESOURCE_CHOICES)
    study = selectable.AutoCompleteSelectField(
        lookup_class=StudyLookup,
        help_text=
        "Type a few characters of the study name, then click to select.")
    endpoint = selectable.AutoCompleteSelectField(
        lookup_class=EndpointByAssessmentLookup,
        help_text=
        "Type a few characters of the endpoint name, then click to select.")
    visual = selectable.AutoCompleteSelectField(
        lookup_class=lookups.VisualLookup,
        help_text=
        "Type a few characters of the visual name, then click to select.")
    data_pivot = selectable.AutoCompleteSelectField(
        lookup_class=lookups.DataPivotLookup,
        help_text=
        "Type a few characters of the data-pivot name, then click to select.")
    display_type = forms.ChoiceField(
        choices=DISPLAY_TYPE_CHOICES,
        help_text=
        "A popup will appear as a hyperlink which a user can select to see more details; an inline visual is shown on page-load."
    )
    title = forms.CharField(
        help_text=
        "This is the inline text-displayed as a hyperlink; if user clicks, then the resource is presented in a popup."
    )
    caption = forms.CharField(
        widget=forms.Textarea(attrs={'rows': 3}),
        help_text=
        "This is caption presented beneath an inline display of the selected resource."
    )

    def __init__(self, *args, **kwargs):
        assessment_id = kwargs.pop('assessment_id', -1)
        super(SmartTagForm, self).__init__(*args, **kwargs)
        for fld in self.fields.keys():
            widget = self.fields[fld].widget
            widget.attrs['class'] = 'span12'
            if hasattr(widget, 'update_query_parameters'):
                widget.update_query_parameters({'related': assessment_id})
                widget.attrs['class'] += " smartTagSearch"
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        """
        Adds author fields to form and fills field with assigned reviewer if
        one exists.

         - If the number_of_reviewers on study's assessment is 1, then no
            author fields are generated, only the final_author.
         - If the number_of_reviewers is 2 or more, then int(number_of_reviewers)
            author fields are generated in addition to the final_author field.
        """
        super().__init__(*args, **kwargs)
        self.instance_name = "Study"
        assessment_id = self.instance.assessment_id
        if hasattr(self.instance_name, "active_riskofbiases"):
            robs = self.instance.active_riskofbiases
        else:
            robs = self.instance.get_active_robs(with_final=False)

        try:
            reviewers = self.instance.assessment.rob_settings.number_of_reviewers
        except ObjectDoesNotExist:
            reviewers = 0

        if reviewers > 1:
            for i in range(reviewers):
                author_field = f"author-{i}"
                self.fields[author_field] = selectable.AutoCompleteSelectField(
                    lookup_class=AssessmentTeamMemberOrHigherLookup,
                    label="Reviewer",
                    required=False,
                    widget=selectable.AutoCompleteSelectWidget,
                )
                self.fields[author_field].widget.update_query_parameters(
                    {"related": assessment_id})
                try:
                    self.fields[author_field].initial = robs[i].author.id
                except IndexError:
                    pass

        self.fields["final_author"] = selectable.AutoCompleteSelectField(
            lookup_class=AssessmentTeamMemberOrHigherLookup,
            label="Final Reviewer",
            required=False,
            widget=selectable.AutoCompleteSelectWidget,
        )
        self.fields["final_author"].widget.update_query_parameters(
            {"related": assessment_id})
        try:
            self.fields["final_author"].initial = self.instance.get_final_rob(
            ).author.id
        except (ObjectDoesNotExist, AttributeError):
            pass
Ejemplo n.º 7
0
class AddSpeakerForm(forms.Form):

    email = selectable.AutoCompleteSelectField(
        lookup_class=UserLookup,
        allow_new=True,
        label=_("Email address"),
        required=True,
    )

    def __init__(self, *args, **kwargs):
        self.proposal = kwargs.pop("proposal")
        super(AddSpeakerForm, self).__init__(*args, **kwargs)

    def clean_email(self):
        value = self.cleaned_data["email"]
        # django-selectable returns the user
        if isinstance(value, UserLookup.model):
            value = value.email
        if value == self.proposal.speaker.email:
            raise forms.ValidationError(
                _("You have submitted the Proposal author's email address. Please" \
                " select another email address.")
            )
        exists = self.proposal.additional_speakers.filter(
            Q(user=None, invite_email=value) | Q(user__email=value)).exists()
        if exists:
            raise forms.ValidationError(
                _("This email address has already been invited to your talk proposal"
                  ))
        return value
Ejemplo n.º 8
0
class QuickSearchForm(forms.Form):
    quick_search = selectable.AutoCompleteSelectField(
        QuickLookup,
        label='Quick Search',
        required=False
    )
    quick_search.widget.attrs['placeholder'] = 'Search'

    def clean_quick_search(self):
        item = self.cleaned_data['quick_search']

        if item is not None:
            try:
                item = item.split('-')
                if len(item) == 1 or '' in item:
                    raise ValueError
                return item
            except ValueError:
                raise forms.ValidationError('%s' %
                    'User, business, or project does not exist')
        else:
            raise forms.ValidationError('%s' %
                'User, business, or project does not exist')

    def save(self):
        type, pk = self.cleaned_data['quick_search']

        if type == 'individual':
            return reverse('view_user', args=(pk,))
        elif type == 'business':
            return reverse('view_business', args=(pk,))
        elif type == 'project':
            return reverse('view_project', args=(pk,))

        raise forms.ValidationError('Must be a user, project, or business')
Ejemplo n.º 9
0
class BaseReleaseMediaForm(ModelForm):
    class Meta:
        model = Media
        parent_model = Release
        formset = BaseReleaseMediaFormSet
        fields = (
            'name',
            'tracknumber',
        )

    def __init__(self, *args, **kwargs):
        self.instance = kwargs['instance']
        super(BaseReleaseMediaForm, self).__init__(*args, **kwargs)
        if self.instance and self.instance.release and self.instance.release.publish_date:
            self.fields['license'].widget.attrs['readonly'] = True
            #self.fields['license'].widget = forms.TextInput(attrs={'readonly':'readonly'})

    artist = selectable.AutoCompleteSelectField(ArtistLookup,
                                                allow_new=True,
                                                required=False)
    tracknumber = forms.CharField(label=_('No.'))

    def clean_license(self):
        instance = getattr(self, 'instance', None)
        if instance and instance.release.publish_date:
            return instance.license
        else:
            return self.cleaned_data['license']
Ejemplo n.º 10
0
class BaseAlbumartistForm(ModelForm):
    class Meta:
        model = ReleaseAlbumartists
        parent_model = Release
        fields = (
            'artist',
            'join_phrase',
            'position',
        )

    def __init__(self, *args, **kwargs):
        super(BaseAlbumartistForm, self).__init__(*args, **kwargs)
        instance = getattr(self, 'instance', None)

    def clean_artist(self):

        artist = self.cleaned_data['artist']
        if artist and not artist.pk:
            log.debug('saving not existant artist: %s' % artist.name)
            artist.save()

        return artist

    artist = selectable.AutoCompleteSelectField(ArtistLookup,
                                                allow_new=True,
                                                required=False)
Ejemplo n.º 11
0
class ObservationFilterForm(forms.Form):

    participant = selectable.AutoCompleteSelectField(lookup_class=UserLookup,
                                                     required=False)
    hide_complete = forms.BooleanField(initial=True, required=False)
    site = forms.ModelChoiceField(queryset=StudySite.objects.all(),
                                  required=False)
Ejemplo n.º 12
0
class UserMessageForm(forms.ModelForm):
    """Form to send Emails or SMS messages to users and store a record."""

    message_to = selectable.AutoCompleteSelectField(
        label='To:',
        help_text=
        "Type part of the participant's name, userid or email for autocompletion.",
        lookup_class=UserLookup,
        required=True,
    )

    class Meta:
        model = UserMessage
        exclude = ['message_from', 'state']

    def clean(self):
        """SMS messages can't have subject lines and are < 130 characters"""

        cleaned_data = self.cleaned_data
        message_type = cleaned_data.get("message_type")
        subject = cleaned_data.get("subject")
        message = cleaned_data.get("message")

        if message_type == "SMS" and subject:
            raise forms.ValidationError("SMS messages cannot have a subject.")

        if message_type == "SMS" and len(message) > 130:
            raise forms.ValidationError(
                "SMS messages cannot be over 130 characters long.")

        return cleaned_data
Ejemplo n.º 13
0
class ProjectForm(forms.ModelForm):
    class Meta:
        model = Project
        fields = (
            'name',
            'business',
            'tracker_url',
            'point_person',
            'type',
            'status',
            'activity_group',
            'description',
        )

    business = selectable.AutoCompleteSelectField(
        BusinessLookup,
        label='Business',
        required=True
    )
    business.widget.attrs['placeholder'] = 'Search'

    def __init__(self, *args, **kwargs):
        super(ProjectForm, self).__init__(*args, **kwargs)

    def save(self):
        instance = super(ProjectForm, self).save(commit=False)
        instance.save()
        return instance
Ejemplo n.º 14
0
class ShowIfForm(forms.ModelForm):
    previous_question = selectable.AutoCompleteSelectField(lookup_class=QuestionLookup,
        required=False)

    class Meta(object):
        model = ShowIf
        exclude = []
Ejemplo n.º 15
0
class ChainedForm(forms.Form):
    city = selectable.AutoCompleteSelectField(
        lookup_class=CityLookup,
        label='City',
        required=False,
        widget=selectable.AutoComboboxSelectWidget)
    state = USStateField(widget=USStateSelect, required=False)
Ejemplo n.º 16
0
class BaseExtraartistForm(ModelForm):
    class Meta:
        model = MediaExtraartists
        parent_model = Media
        fields = (
            'artist',
            'profession',
        )
        # labels in django 1.6 only... leave them here for the future...
        labels = {
            'profession': _('Credited as'),
        }

    def __init__(self, *args, **kwargs):
        super(BaseExtraartistForm, self).__init__(*args, **kwargs)
        instance = getattr(self, 'instance', None)

        self.fields['profession'].label = _('Credited as')

    artist = selectable.AutoCompleteSelectField(ArtistLookup,
                                                allow_new=True,
                                                required=False,
                                                label=_('Artist'))

    def clean_artist(self):

        artist = self.cleaned_data['artist']
        try:
            if not artist.pk:
                log.debug('saving not existant artist: %s' % artist.name)
                artist.save()
            return artist
        except:
            return None
Ejemplo n.º 17
0
class CreateEditProjectForm(forms.ModelForm):
    business = selectable.AutoCompleteSelectField(BusinessLookup)
    business.widget.attrs['placeholder'] = 'Search'

    class Meta:
        model = Project
        fields = ('name', 'business', 'tracker_url', 'point_person', 'type',
                  'status', 'activity_group', 'description')
Ejemplo n.º 18
0
class AdminLookupForm(forms.Form):
    person = selectable.AutoCompleteSelectField(
        lookup_class=lookups.AdminLookup,
        label='Administrator',
        required=True,
        help_text=AUTOCOMPLETE_HELP_TEXT,
        widget=selectable.AutoComboboxSelectWidget,
    )
Ejemplo n.º 19
0
class PersonMergeForm(forms.Form):

    person_from = selectable.AutoCompleteSelectField(
        lookup_class=lookups.PersonLookup,
        label='Person From',
        required=True,
        help_text=AUTOCOMPLETE_HELP_TEXT,
        widget=selectable.AutoComboboxSelectWidget,
    )

    person_to = selectable.AutoCompleteSelectField(
        lookup_class=lookups.PersonLookup,
        label='Person To',
        required=True,
        help_text=AUTOCOMPLETE_HELP_TEXT,
        widget=selectable.AutoComboboxSelectWidget,
    )
Ejemplo n.º 20
0
class EntityRelationshipForm(PropertyAssertionForm):

    relationship_type = forms.ChoiceField(choices=[])
    related_entity = selectable.AutoCompleteSelectField(
        lookup_class=EntityLookup)
    certainty = forms.BooleanField(required=False)

    def __init__(self, *args, **kwargs):
        relationship_type_choices = kwargs.pop('relationship_type_choices')
        super(EntityRelationshipForm, self).__init__(*args, **kwargs)
        self.fields['relationship_type'].choices = relationship_type_choices

    def _assertion_to_dict(self, assertion):
        data = super(EntityRelationshipForm,
                     self)._assertion_to_dict(assertion)
        relationship_id = str(assertion.entity_relationship_type.get_id())
        direction_marker = FORWARD_RELATIONSHIP_MARKER
        related_entity = assertion.range_entity
        if self.entity == assertion.range_entity:
            direction_marker = REVERSE_RELATIONSHIP_MARKER
            related_entity = assertion.domain_entity
        data['relationship_type'] = relationship_id + direction_marker
        data['related_entity'] = related_entity.get_id()
        if assertion.certainty == \
                self.topic_map.property_assertion_full_certainty:
            certainty = True
        else:
            certainty = False
        data['certainty'] = certainty
        return data

    def save(self):
        relationship_type_id = self.cleaned_data['relationship_type']
        relationship_type = EntityRelationshipType.objects.get_by_identifier(
            relationship_type_id[:-1])
        # The autocomplete selection library, via lookups.py, takes
        # care of retrieving the entity from its id.
        related_entity = self.cleaned_data['related_entity']
        direction = relationship_type_id[-1]
        if direction == FORWARD_RELATIONSHIP_MARKER:
            domain_entity = self.entity
            range_entity = related_entity
        elif direction == REVERSE_RELATIONSHIP_MARKER:
            domain_entity = related_entity
            range_entity = self.entity
        if self.cleaned_data['certainty']:
            certainty = self.topic_map.property_assertion_full_certainty
        else:
            certainty = self.topic_map.property_assertion_no_certainty
        if self.instance is None:
            # Create a new assertion.
            self.entity.create_entity_relationship_property_assertion(
                self.authority, relationship_type, domain_entity, range_entity,
                certainty)
        else:
            # Update an existing assertion.
            self.instance.update(relationship_type, domain_entity,
                                 range_entity, certainty)
Ejemplo n.º 21
0
 def setupSelector(self, parent_id):
     fld = selectable.AutoCompleteSelectField(
         lookup_class=self.lookup_class,
         allow_new=False,
         label=self.label,
         widget=selectable.AutoComboboxSelectWidget)
     fld.widget.update_query_parameters({'related': parent_id})
     fld.widget.attrs['class'] = 'span11'
     self.fields['selector'] = fld
Ejemplo n.º 22
0
class ProductivityReportForm(forms.Form):
    ORGANIZE_BY_CHOICES = (
        ('week', 'Week'),
        ('user', 'User'),
    )
    project = selectable.AutoCompleteSelectField(ProjectLookup)
    organize_by = forms.ChoiceField(choices=ORGANIZE_BY_CHOICES,
                                    widget=forms.RadioSelect(),
                                    initial=ORGANIZE_BY_CHOICES[0][0])
Ejemplo n.º 23
0
class ReleaseBulkeditForm(Form):
    def __init__(self, *args, **kwargs):

        self.instance = kwargs.pop('instance', False)
        self.disable_license = False
        if self.instance and self.instance.publish_date:
            self.disable_license = True

        super(ReleaseBulkeditForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_id = "bulk_edit%s" % 'asd'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_method = 'post'
        self.helper.form_action = ''
        self.helper.form_tag = False

        form_class = 'input-xlarge'
        if self.disable_license:
            form_class = 'hidden'

        base_layout = Div(
            Div(HTML(
                '<h4>%s</h4><p>%s</p>' %
                (_('Bulk Edit'),
                 _('Choose Artist name and/or license to apply on every track.'
                   ))),
                css_class='form-help'),
            Row(
                Column(Field('bulk_artist_name', css_class='input-xlarge'),
                       css_class='span6'),
                Column(HTML(
                    '<button type="button" id="bulk_apply_artist_name" value="apply" class="btn btn-mini pull-right bulk_apply" id="submit-"><i class="icon-plus"></i> %s</button>'
                    % _('Apply Artist to all tracks')),
                       css_class='span2'),
                css_class='releasemedia-row row',
            ),
            Row(
                Column(Field('bulk_license', css_class=form_class),
                       css_class='span6'),
                Column(HTML(
                    '<button type="button" id="bulk_apply_license" value="apply" class="btn btn-mini pull-right bulk_apply" id="submit-"><i class="icon-plus"></i> %s</button>'
                    % _('Apply License to all tracks')),
                       css_class='span2'),
                css_class='releasemedia-row row',
            ),
            css_class='bulk_edit',
        )

        self.helper.add_layout(base_layout)

    # Fields
    bulk_artist_name = selectable.AutoCompleteSelectField(ArtistLookup,
                                                          allow_new=True,
                                                          required=False,
                                                          label=_('Artist'))
Ejemplo n.º 24
0
 def setupSelector(self, parent_id):
     fld = selectable.AutoCompleteSelectField(
         lookup_class=self.lookup_class,
         allow_new=False,
         label=self.label,
         widget=selectable.AutoComboboxSelectWidget,
     )
     fld.widget.update_query_parameters({"related": parent_id})
     fld.widget.attrs["class"] = "span11"
     self.fields["selector"] = fld
Ejemplo n.º 25
0
class ProductivityReportForm(forms.Form):
    DATE_FORMAT = '%Y-%m-%d'
    ORGANIZE_BY_CHOICES = (
        ('week', 'Week'),
        ('person', 'People'),
    )
    project = selectable_forms.AutoCompleteSelectField(ProjectLookup)
    organize_by = forms.ChoiceField(choices=ORGANIZE_BY_CHOICES,
                                    widget=forms.RadioSelect(),
                                    initial=ORGANIZE_BY_CHOICES[0][0])
Ejemplo n.º 26
0
class CreateMembershipForm(forms.ModelForm):
    """Used to add a participant to a Study."""

    user = selectable.AutoCompleteSelectField(
        label='Type the name of the participant',
        lookup_class=UserLookup,
        required=True,
    )
    relates_to = selectable.AutoCompleteSelectField(
        label='(Optional) patient to link this membership to:',
        lookup_class=MembershipLookup,
        required=False,
    )

    date_randomised = forms.DateField(help_text="""Format: dd/mm/yyyy""",
                                      required=False)

    class Meta:
        model = Membership
        fields = ['user', 'study', 'relates_to', 'date_randomised']
Ejemplo n.º 27
0
class MetaResultSelectorForm(forms.Form):

    selector = selectable.AutoCompleteSelectField(
        lookup_class=lookups.MetaResultByStudyLookup,
        label='Meta Result',
        widget=selectable.AutoComboboxSelectWidget)

    def __init__(self, *args, **kwargs):
        super(MetaResultSelectorForm, self).__init__(*args, **kwargs)
        for fld in self.fields.keys():
            self.fields[fld].widget.attrs['class'] = 'span11'
Ejemplo n.º 28
0
class ReplyReassignmentDetailForm(forms.ModelForm):

    observation = selectable.AutoCompleteSelectField(
        label=
        'Search for observation ID or part of a username to find the correct observation',
        lookup_class=ObservationLookup,
        required=True,
    )

    class Meta:
        model = Reply
        fields = ['observation']
Ejemplo n.º 29
0
class FindParticipantForm(forms.Form):
    """Quick lookup (autocompleted) form to find a participant.

    Would normally then redirect to overview."""

    participant = selectable.AutoCompleteSelectField(
        label='Find a participant',
        lookup_class=UserLookup,
        required=True,
        allow_new=True,
        help_text="Type part of the participant's name/userid to autocomplete."
    )
Ejemplo n.º 30
0
class BadgeAwardForm(forms.ModelForm):

    person = selectable.AutoCompleteSelectField(
        lookup_class=lookups.PersonLookup,
        label='Person',
        required=True,
        help_text=AUTOCOMPLETE_HELP_TEXT,
        widget=selectable.AutoComboboxSelectWidget,
    )

    event = selectable.AutoCompleteSelectField(
        lookup_class=lookups.EventLookup,
        label='Event',
        required=False,
        help_text=AUTOCOMPLETE_HELP_TEXT,
        widget=selectable.AutoComboboxSelectWidget,
    )

    class Meta:
        model = Award
        fields = '__all__'
        widgets = {'badge': HiddenInput}