Beispiel #1
0
 def __init__ (self, topic_map, model, data=None, instance=None, **kwargs):
     super(AuthorityForm, self).__init__(topic_map, model, data=data,
                                         instance=instance, **kwargs)
     self.fields['calendars'].choices = create_choice_list(
         topic_map, Calendar.objects.all())[1:]
     self.fields['date_periods'].choices = create_choice_list(
         topic_map, DatePeriod.objects.all())[1:]
     self.fields['date_types'].choices = create_choice_list(
         topic_map, DateType.objects.all())[1:]
     self.fields['entity_relationship_types'].choices = create_choice_list(
         topic_map, EntityRelationshipType.objects.all())[1:]
     self.fields['entity_types'].choices = create_choice_list(
         topic_map, EntityType.objects.all())[1:]
     self.fields['languages'].choices = create_choice_list(
         topic_map, Language.objects.all())[1:]
     self.fields['name_types'].choices = create_choice_list(
         topic_map, NameType.objects.all())[1:]
     self.fields['name_part_types'].choices = create_choice_list(
         topic_map, NamePartType.objects.all())[1:]
     self.fields['scripts'].choices = create_choice_list(
         topic_map, Script.objects.all())[1:]
     self.fields['editors'].choices = [(editor.user.pk, editor.user.username) for editor in EATSUser.objects.all()]
Beispiel #2
0
    def _create_form_fields (self, post_data, instance_data):
        """Creates dynamic fields to accomodate the post/instance data.

        :param post_data: POSTed data
        :type post_data: dictionary
        :param instance_data: `Language` instance data
        :type instance_data: dictionary

        """
        name_part_type_choices = create_choice_list(
            self.topic_map, NamePartType.objects.all())
        data = post_data or instance_data
        count = 2
        for name in data:
            if name.startswith(self.npt_base_name):
                count += 1
        count = max(count, 3)
        for i in range(count):
            self.fields[self.npt_base_name + str(i)] = forms.ChoiceField(
                choices=name_part_type_choices, required=False,
                label='Name part type %s' % str(i+1))
Beispiel #3
0
 def __init__ (self, topic_map, *args, **kwargs):
     entity_types = kwargs.pop('entity_types', [])
     super(EntitySearchForm, self).__init__(*args, **kwargs)
     self.fields['entity_type'].choices = create_choice_list(
         topic_map, entity_types)
Beispiel #4
0
 def __init__(self, topic_map, *args, **kwargs):
     entity_types = kwargs.pop('entity_types', [])
     super(EntitySearchForm, self).__init__(*args, **kwargs)
     self.fields['entity_type'].choices = create_choice_list(
         topic_map, entity_types)