Exemplo n.º 1
0
 class Meta:
     model = Practica
     fields = ["cliente", "tipoDeAtencion"]
     labels = {"tipoDeAtencion": "Tipo de atención"}
     help_texts = {
         "cliente":
         "Debe agregar un cliente al cual asociarle la práctica. Puede seleccionarlo buscandolo por nombre, apellido o DNI.",
         "tipoDeAtencion": "Elija el tipo de atención correspondiente.",
     }
     widgets = {
         "cliente":
         ModelSelect2(url=reverse_lazy("autocomplete:cliente"),
                      attrs={"data-allow-clear": "false"}),
         "tipoDeAtencion":
         ModelSelect2(url=reverse_lazy("autocomplete:tipoDeAtencion"),
                      attrs={"data-allow-clear": "false"}),
     }
     field_classes = {
         "cliente": ClienteModelChoiceField,
         "tipoDeAtencion": TipoDeAtencionModelChoiceField,
     }
     error_messages = {
         "cliente": {
             "required": "Debe seleccionar un cliente",
             "invalid_choice":
             "El cliente seleccionado no es una opción válida"
         },
         "tipoDeAtencion": {
             "required":
             "Debe seleccionar un tipo de atención",
             "invalid_choice":
             "El tipo de atención seleccionado no es una opción válida"
         }
     }
Exemplo n.º 2
0
 class Meta:
     model = Work
     fields = [
         "conference",
         "title",
         "url",
         "work_type",
         "full_text",
         "full_text_type",
         "full_text_license",
         "keywords",
         "languages",
         "topics",
         "parent_session",
     ]
     widgets = {
         "keywords": ModelSelect2Multiple(url="keyword-autocomplete"),
         "topics": ModelSelect2Multiple(url="topic-autocomplete"),
         "languages": ModelSelect2Multiple(url="language-autocomplete"),
         "conference": ModelSelect2(url="conference-autocomplete"),
         "parent_session": ModelSelect2(
             url="work-autocomplete",
             forward=["conference", forward.Const(True, "parents_only")],
         ),
     }
Exemplo n.º 3
0
 class Meta:
     model = Region
     widgets = {
         'country': ModelSelect2(url='country-autocomplete'),
         'geocoordinate': ModelSelect2(url='geocoordinate-autocomplete'),
     }
     fields = '__all__'
Exemplo n.º 4
0
 class Meta:
     model = City
     widgets = {
         'zipcode': ModelSelect2(url='zipcode-autocomplete'),
         'county': ModelSelect2(url='county-autocomplete'),
         'geocoordinate': ModelSelect2(url='geocoordinate-autocomplete'),
     }
     fields = '__all__'
Exemplo n.º 5
0
 class Meta:
     model = Cultivar
     widgets = {
         'origin_location': ModelSelect2(url='location-autocomplete'),
         'species': ModelSelect2(url='species-autocomplete'),
         'parent_a': ModelSelect2(url='cultivar-autocomplete'),
         'parent_b': ModelSelect2(url='cultivar-autocomplete'),
     }
     fields = '__all__'
Exemplo n.º 6
0
class AuthorFilter(forms.Form):
    ordering = forms.ChoiceField(
        choices=(
            ("last_name", "Last name (A-Z)"),
            ("-last_name", "Last name (Z-A)"),
            ("-n_works", "By number of abstracts (descending)"),
            ("n_works", "By number of abstracts (ascending)"),
        ),
        required=False,
        initial="last_name",
    )
    author = forms.ModelChoiceField(
        queryset=Author.objects.all(),
        required=False,
        widget=ModelSelect2(url="author-autocomplete", attrs={"data-html": True}),
    )
    name = forms.CharField(max_length=100, strip=True, required=False)
    first_name = forms.CharField(
        max_length=100,
        strip=True,
        required=False,
        label="First/middle name",
        help_text="Search only first and middle names",
    )
    last_name = forms.CharField(
        max_length=100, strip=True, required=False, help_text="Search only last names"
    )
    country = forms.ModelChoiceField(
        queryset=Country.objects.all(),
        required=False,
        help_text="Authors who were once affiliated with an institution in this country",
        widget=ModelSelect2(url="country-autocomplete"),
    )
    institution = forms.ModelChoiceField(
        queryset=Institution.objects.all(),
        required=False,
        widget=ModelSelect2(url="institution-autocomplete", attrs={"data-html": True}),
        help_text="Authors who were once affiliated with this institution",
    )
    affiliation = forms.ModelChoiceField(
        queryset=Affiliation.objects.all(),
        required=False,
        widget=ModelSelect2(url="affiliation-autocomplete", attrs={"data-html": True}),
        help_text='Search by department+institution combination. This is a more granular search than "Institution" above.',
    )
    conference = forms.ModelChoiceField(
        queryset=Conference.objects.all(),
        required=False,
        widget=ModelSelect2(url="conference-autocomplete", attrs={"data-html": True}),
        help_text="Show authors with works submitted to this conference.",
    )
    singleton = forms.BooleanField(
        required=False, help_text="Show authors who only appear in one conference."
    )
Exemplo n.º 7
0
 class Meta:
     model = Flight
     fields = '__all__'
     widgets = {
         'orig':
         ModelSelect2(url='travels:airport-autocomplete',
                      attrs={'class': 'form-control'}),
         'dest':
         ModelSelect2(url='travels:airport-autocomplete',
                      attrs={'class': 'form-control'}),
         'airline':
         ModelSelect2(url='travels:airline-autocomplete',
                      attrs={'class': 'form-control'})
     }
Exemplo n.º 8
0
 class Meta:
     model = FruitReview
     widgets = {
         'cultivar':
         ModelSelect2(url='cultivar-autocomplete'),
         'fruiting_plant':
         ModelSelect2(url='fruiting-plant-autocomplete'),
         'datetime':
         DateTimeWidget(attrs={'id': 'datetime-id'},
                        usel10n=True,
                        bootstrap_version=3),
     }
     fields = ('submitted_by', 'datetime', 'cultivar', 'fruiting_plant',
               'sweet', 'sour', 'bitter', 'juicy', 'firm',
               'was_picked_early', 'rating', 'text')
Exemplo n.º 9
0
class WorkAuthorshipForm(forms.Form):
    author = forms.ModelChoiceField(
        queryset=Author.objects.all(),
        required=False,
        widget=ModelSelect2(url="author-autocomplete", attrs={"data-html": True}),
        help_text="If the author currently exists, select them to auto-populate the fields below. Any edits to the details below will be stored as new assertions about this author. If the author does not yet exist, leave this field blank and they will be created from the information you enter below.",
    )
    authorship_order = forms.IntegerField(
        min_value=1,
        help_text="Authorship order must be unique across all the authorships of this work.",
    )
    first_name = forms.CharField(
        max_length=100,
        required=True,
        label="First and middle names",
        help_text="First and middle names/initials as it appears in the context of this abstract.",
    )
    last_name = forms.CharField(
        max_length=100,
        required=True,
        help_text="Last name as it appears in the context of this abstract.",
    )
    affiliations = forms.ModelMultipleChoiceField(
        queryset=Affiliation.objects.all(),
        required=False,
        widget=ModelSelect2Multiple(
            url="affiliation-autocomplete",
            attrs={"data-html": True},
            forward=["institution"],
        ),
        help_text="If the combination of department and institution is not available in this list, then use the fields below to define it.",
    )
    institution = forms.ModelChoiceField(
        queryset=Institution.objects.all(),
        required=False,
        widget=ModelSelect2(url="institution-autocomplete", attrs={"data-html": True}),
        help_text="Use this optional menu to filter the affiliation list below. This value is only used for filtering and does not affect the final affiliation data that gets saved.",
    )

    def clean(self):
        cleaned_data = super().clean()
        affiliations = cleaned_data.get("affiliations")
        institution = cleaned_data.get("institution")
        if institution is not None and len(affiliations) < 1:
            self.add_error(
                "affiliations",
                "You must enter a specific affiliation for each author. It is not sufficient to only select an institution - that field is used only to filter the available affiliations.",
            )
Exemplo n.º 10
0
        def __init__(self, *args, **kwargs):
            model = kwargs.pop('model')
            request = kwargs.pop('request')
            self.field_path = kwargs.pop('field_path')
            value = kwargs.get('data').get(self.field_path)
            fields = get_fields_from_path(model, self.field_path)
            url = 'filter_model_autocomplete' if fields[0].is_relation else 'filter_list_autocomplete'
            is_relation = url == 'filter_model_autocomplete'

            if value:
                choices = [(value, value)]
            else:
                choices = []

            super(AutocompleteForm, self).__init__(*args, **kwargs)
            url = reverse(
                url,
                kwargs={
                    'app': model._meta.app_label,
                    'model': model._meta.model_name,
                    'field_path': self.field_path
                }
            )
            if request.GET:
                url = '%s?%s' % (url, request.GET.urlencode())

            if is_relation:
                self.fields[self.field_path] = forms.ModelChoiceField(
                    queryset=model._default_manager.none(), required=False, widget=ModelSelect2(url=url)
                )
            else:
                self.fields[self.field_path] = forms.ChoiceField(
                    choices=choices, required=False, widget=ListSelect2(url=url),
                )
Exemplo n.º 11
0
class CirugiaServicioForm(PracticaServicioForm):

    cantidad = forms.IntegerField(
        required=True,
        min_value=1,
        widget=forms.TextInput(attrs={'class': 'form-control'}),
        error_messages={
            "required": "La cantidad es obligatoria",
            "invalid": "La cantidad debe ser un numero entero",
            "min_value": "La cantidad debe ser mayor que cero",
        })

    servicio = ServicioModelChoiceField(
        queryset=Servicio.objects.habilitados().filter(tipo=Areas.Q.codigo()),
        empty_label=None,
        to_field_name="id",
        widget=ModelSelect2(url=reverse_lazy("autocomplete:servicio",
                                             args=(Areas.Q.codigo(), )),
                            attrs={
                                "data-allow-clear": "false",
                            }),
        error_messages={
            "required": "El servicio es obligatorio",
            "invalid_choice":
            "El servicio seleccionado no es una opción válida",
        })
Exemplo n.º 12
0
class LanguageMergeForm(forms.Form):
    into = forms.ModelChoiceField(
        queryset=Language.objects.all(),
        widget=ModelSelect2(url="language-autocomplete"),
        required=True,
        help_text="Select the language that will be used to replace the one you are deleting.",
    )
Exemplo n.º 13
0
class PracticaProductoForm(forms.Form):

    cantidad = forms.IntegerField(
        min_value=1,
        widget=forms.TextInput(attrs={'class': 'form-control'}),
        error_messages={
            "required": "La cantidad es obligatoria",
            "invalid": "La cantidad debe ser un numero entero",
            "min_value": "La cantidad debe ser mayor que cero",
        })

    producto = ProductoModelChoiceField(
        empty_label=None,
        to_field_name="id",
        queryset=Producto.objects.habilitados(),
        widget=ModelSelect2(url=reverse_lazy("autocomplete:insumo"),
                            attrs={
                                "data-allow-clear": "false",
                            }),
        error_messages={
            "required": "El producto es obligatorio",
            "invalid_choice":
            "El producto seleccionado no es una opción válida",
        })

    def clean(self):
        retorno = super().clean()
        if not self.errors:
            retorno["producto"] = retorno["producto"].id
        return retorno
Exemplo n.º 14
0
 class Meta:
     model = Conference
     fields = [
         "year",
         "short_title",
         "theme_title",
         "hosting_institutions",
         "url",
         "city",
         "state_province_region",
         "country",
         "organizers",
         "start_date",
         "end_date",
         "notes",
         "references",
         "contributors",
         "attendance",
         "entry_status",
         "program_available",
         "abstracts_available",
         "license_action",
     ]
     widgets = {
         "entry_status": forms.RadioSelect(choices=Conference.ENTRY_STATUS),
         "start_date": forms.DateInput(attrs={"type": "date"}),
         "end_date": forms.DateInput(attrs={"type": "date"}),
         "country": ModelSelect2(url="country-autocomplete"),
         "hosting_institutions": ModelSelect2Multiple(
             url="institution-autocomplete", attrs={"data-html": True}
         ),
         "references": forms.Textarea(attrs={"rows": 2}),
         "contributors": forms.Textarea(attrs={"rows": 2}),
         "attendance": forms.Textarea(attrs={"rows": 2}),
     }
Exemplo n.º 15
0
 class Meta:
     model = FruitingPlant
     fields = [
         'created_by',
         'species',
         'cultivar',
         'location',
         'date_planted',
     ]
     widgets = {
         'created_by': HiddenInput(),
         'species': ModelSelect2(url='species-autocomplete'),
         'cultivar': ModelSelect2(url='cultivar-autocomplete'),
         'location': ModelSelect2(url='location-autocomplete'),
         'date_planted': DateWidget(usel10n=True, bootstrap_version=3),
     }
Exemplo n.º 16
0
    def __init__(self, *args, practica=None, mascota_required=True, **kwargs):
        super().__init__(*args, **kwargs)
        self.practica = practica

        if (self.practica is not None) and (self.practica.mascota is None):
            mascotas = self.practica.cliente.mascota_set
            self.fields["mascota"] = MascotaModelChoiceField(
                to_field_name="id",
                queryset=mascotas.habilitados(),
                widget=ModelSelect2(url=reverse_lazy(
                    "autocomplete:mascota", args=(self.practica.cliente.id, )),
                                    attrs={"data-allow-clear": "false"}),
                help_text=
                "Seleccione a cual mascota del cliente se registrará la práctica.",
                error_messages={
                    "required":
                    "Debe seleccionar alguna mascota",
                    "invalid_choice":
                    "La mascota seleccionada no es una opción válida"
                })
            self.fields.move_to_end("mascota", last=False)
            if mascota_required:
                self.fields["mascota"].empty_label = None
            else:
                self.fields["mascota"].required = False
Exemplo n.º 17
0
class AffiliationMergeForm(forms.Form):
    into = forms.ModelChoiceField(
        queryset=Affiliation.objects.all(),
        widget=ModelSelect2(url="affiliation-autocomplete", attrs={"data-html": True}),
        required=True,
        help_text="Select the affiliation that will be used to replace the one you are deleting.",
    )
Exemplo n.º 18
0
        def __init__(self, request, model, field_path, *args, **kwargs):
            self.field_path = field_path
            value = kwargs.get('data').get(self.field_path)
            fields = get_fields_from_path(model, self.field_path)
            is_relation = fields[0].is_relation
            url = 'filter_model_autocomplete' if is_relation else 'filter_list_autocomplete'

            super(AutocompleteForm, self).__init__(*args, **kwargs)
            url = reverse(
                url,
                kwargs={
                    'app': model._meta.app_label,
                    'model': model._meta.model_name,
                    'field_path': self.field_path
                }
            )
            if request.GET:
                url = '%s?%s' % (url, request.GET.urlencode())

            if is_relation:
                related_model = get_model_from_relation(fields[-1])
                qs = related_model._default_manager.all()
                if value:
                    qs = qs.filter(pk=value)
                self.fields[self.field_path] = forms.ModelChoiceField(
                    queryset=qs, required=False, widget=ModelSelect2(url=url)
                )
            else:
                choices = [(value, value)] if value else []
                self.fields[self.field_path] = forms.ChoiceField(
                    choices=choices, required=False, widget=ListSelect2(url=url),
                )
Exemplo n.º 19
0
 class Meta:
     model = RealizadaProducto
     fields = ["cantidad", "producto"]
     widgets = {
         "producto":
         ModelSelect2(url=reverse_lazy("autocomplete:insumo"),
                      attrs={
                          "data-allow-clear": "false",
                      }),
         "cantidad":
         forms.TextInput(attrs={'class': 'form-control'}),
     }
     error_messages = {
         "cantidad": {
             "required": "La cantidad es obligatoria",
             "invalid": "La cantidad debe ser un numero entero",
         },
         "producto": {
             "required":
             "El producto es obligatorio",
             "invalid_choice":
             "El producto seleccionado no es una opción válida",
         }
     }
     field_classes = {
         "producto": ProductoModelChoiceField,
     }
Exemplo n.º 20
0
 def __init__(self, *args, **kwargs):
     super(FruitingPlantQuickForm,self).__init__(*args, **kwargs)
     self.fields['cultivar'].widget = CustomRelatedFieldWidgetWrapper(
                                             ModelSelect2(url='cultivar-autocomplete'),
                                             reverse('admin:taxonomy_cultivar_add') + "?_to_field=cultivar_id&_popup=1",
                                             True)
     self.fields['cultivar'].queryset = Cultivar.objects.all()
     self.fields['species'].widget = CustomRelatedFieldWidgetWrapper(
         ModelSelect2(url='species-autocomplete'),
         reverse('admin:taxonomy_species_add') + "?_to_field=species_id&_popup=1",
         True)
     self.fields['species'].queryset = Species.objects.all()
     self.fields['location'].widget = CustomRelatedFieldWidgetWrapper(
         ModelSelect2(url='location-autocomplete'),
         reverse('admin:django_geo_db_location_add') + "?_to_field=location_id&_popup=1",
         True)
     self.fields['location'].queryset = Location.objects.all()
Exemplo n.º 21
0
 class Meta:
     model = EventReport
     widgets = {
         'fruiting_plant': ModelSelect2(url='fruiting-plant-autocomplete'),
         'datetime': DateTimeWidget(attrs={'id': 'datetime-id'}, usel10n=True, bootstrap_version=3),
         }
     fields = (
         'submitted_by', 'datetime', 'fruiting_plant', 'event_type', 'affinity', 'image', 'notes'
     )
Exemplo n.º 22
0
 class Meta:
     model = UserProfile
     fields = [
         'user',
         'location',
         'organization',
     ]
     widgets = {
         'location': ModelSelect2(url='named-location-autocomplete'),
     }
Exemplo n.º 23
0
 class Meta:
     model = Species
     widgets = {
         'origin': ModelSelect2(url='location-autocomplete'),
         'genus': ModelSelect2(url='genus-autocomplete'),
     }
     fields = ['genus',
               'origin',
               'latin_name',
               'name',
               'can_scale_with_pruning',
               'years_till_full_size',
               'full_size_height',
               'full_size_width',
               'years_till_first_production',
               'years_till_full_production',
               'featured_image',
               'google_maps_image_url',
               ]
Exemplo n.º 24
0
class AffiliationEditForm(forms.ModelForm):
    institution = forms.ModelChoiceField(
        queryset=Institution.objects.all(),
        widget=ModelSelect2(url="institution-autocomplete", attrs={"data-html": True}),
        required=True,
    )

    class Meta:
        model = Affiliation
        fields = ["department", "institution"]
Exemplo n.º 25
0
 class Meta:
     model = Profile
     exclude = tuple()
     widgets = {
         'managed_profiles':
         ModelSelect2Multiple(url='profile_autocomplete'),
         'merged_with': ModelSelect2(url='profile_autocomplete'),
         'created_codes': ModelSelect2Multiple(url='code_autocomplete'),
         'received_codes': ModelSelect2Multiple(url='code_autocomplete'),
         'used_codes': ModelSelect2Multiple(url='code_autocomplete'),
     }
Exemplo n.º 26
0
 class Meta:
     model = FruitingPlant
     fields = [
         'fruiting_plant_id',
         'created_by',
         'species',
         'cultivar',
         'location',
         'geocoordinate',
         'date_planted',
         'date_died',
     ]
     widgets = {
         'fruiting_plant_id': HiddenInput(),
         'species': ModelSelect2(url='species-autocomplete'),
         'cultivar': ModelSelect2(url='cultivar-autocomplete'),
         'geocoordinate': ModelSelect2(url='geocoordinate-autocomplete'),
         'location': ModelSelect2(url='named-location-autocomplete'),
         'created_by': ModelSelect2(url='curator-only-user-autocomplete'),
     }
Exemplo n.º 27
0
class FullInstitutionForm(forms.Form):
    department = forms.CharField(
        max_length=500, required=False, help_text="This free-text field is searchable"
    )
    no_department = forms.BooleanField(
        required=False,
        help_text="Show institutions with at least one affiliation that does not specifiy a department?",
    )
    singleton = forms.BooleanField(
        required=False,
        help_text="Show institutions that appear only in one conference (Useful for identifying institutions that ought to be merged.)",
    )
    affiliation = forms.ModelChoiceField(
        queryset=Affiliation.objects.all(),
        required=False,
        widget=ModelSelect2(url="affiliation-autocomplete", attrs={"data-html": True}),
    )
    conference = forms.ModelChoiceField(
        queryset=Conference.objects.all(),
        required=False,
        widget=ModelSelect2(url="conference-autocomplete", attrs={"data-html": True}),
    )
    institution = forms.ModelChoiceField(
        queryset=Institution.objects.all(),
        required=False,
        widget=ModelSelect2(url="institution-autocomplete", attrs={"data-html": True}),
    )
    country = forms.ModelChoiceField(
        queryset=Country.objects.filter().all(),
        required=False,
        widget=ModelSelect2(url="country-autocomplete"),
    )
    ordering = forms.ChoiceField(
        choices=(
            ("a", "A-Z"),
            ("n_dsc", "By number of abstracts (descending)"),
            ("n_asc", "By number of abstracts (ascending)"),
        ),
        required=False,
        initial="n_dsc",
    )
Exemplo n.º 28
0
class ProductIngredientForm(BaseForm, forms.ModelForm):
    product = forms.ModelChoiceField(queryset=Product.objects.all(),
                                     required=True,
                                     widget=forms.HiddenInput())
    ingredient = forms.ModelChoiceField(
        queryset=Product.objects.all(),
        required=True,
        widget=ModelSelect2(url='catalogue:product_autocomplete'),
        label='Συστατικο')

    class Meta:
        model = ProductIngredient
        fields = '__all__'
Exemplo n.º 29
0
class TopicMultiMergeForm(forms.Form):
    sources = forms.ModelMultipleChoiceField(
        queryset=Topic.objects.all(),
        widget=ModelSelect2Multiple(url="topic-autocomplete"),
        required=True,
        help_text="Select the topics that you want to merge together",
    )
    into = forms.ModelChoiceField(
        queryset=Topic.objects.all(),
        widget=ModelSelect2(url="topic-autocomplete"),
        required=True,
        help_text="Select the target topic to merge into",
    )
Exemplo n.º 30
0
class KeywordMultiMergeForm(forms.Form):
    sources = forms.ModelMultipleChoiceField(
        queryset=Keyword.objects.all(),
        widget=ModelSelect2Multiple(url="keyword-autocomplete"),
        required=True,
        help_text="Select the keywords that you want to merge together",
    )
    into = forms.ModelChoiceField(
        queryset=Keyword.objects.all(),
        widget=ModelSelect2(url="keyword-autocomplete"),
        required=True,
        help_text="Select the target keyword to merge into",
    )