Пример #1
0
    def __init__(self, *args, **kwargs):
        self.types_to_set = kwargs.pop('types_to_set', [])
        self.show_production_type_field = kwargs.pop('show_production_type_field', False)
        self.byline_field = BylineField(required=False)
        supertype = kwargs.pop('supertype', None)
        self.widget = ProductionWidget(
            types_to_set=self.types_to_set,
            supertype=supertype,
            show_production_type_field=self.show_production_type_field,
        )

        super().__init__(*args, **kwargs)
Пример #2
0
class ProductionField(forms.Field):
    def __init__(self, *args, **kwargs):
        self.types_to_set = kwargs.pop('types_to_set', [])
        self.show_production_type_field = kwargs.pop('show_production_type_field', False)
        self.byline_field = BylineField(required=False)
        supertype = kwargs.pop('supertype', None)
        self.widget = ProductionWidget(
            types_to_set=self.types_to_set,
            supertype=supertype,
            show_production_type_field=self.show_production_type_field,
        )

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

    def clean(self, value):
        if not value:
            value = None
        else:
            value = ProductionSelection.from_value(value, types_to_set=self.types_to_set)
            value.byline = self.byline_field.clean(value.byline_lookup)

        return super().clean(value)

    def has_changed(self, initial, data):
        initial = ProductionSelection.from_value(initial)
        data = ProductionSelection.from_value(data)
        return data != initial
Пример #3
0
	def __init__(self, *args, **kwargs):
		self.instance = kwargs.pop('instance', Production())
		super(BaseProductionEditCoreDetailsForm, self).__init__(*args, **kwargs)
		self.fields['title'] = forms.CharField(initial=self.instance.title)
		self.fields['byline'] = BylineField(required=False, initial=self.instance.byline_search(), label='By')
		self.fields['release_date'] = FuzzyDateField(required=False, initial=self.instance.release_date,
			help_text='(As accurately as you know it - e.g. "1996", "Mar 2010")')
		self.fields['platforms'] = forms.ModelMultipleChoiceField(required=False, label='Platform',
			initial=[platform.id for platform in self.instance.platforms.all()],
			queryset=Platform.objects.all())
Пример #4
0
	def __init__(self, *args, **kwargs):
		self.instance = kwargs.pop('instance', Production())
		super(CreateProductionForm, self).__init__(*args, **kwargs)
		self.fields['title'] = forms.CharField()
		self.fields['byline'] = BylineField(required=False, label='By')
		self.fields['release_date'] = FuzzyDateField(required=False,
			help_text='(As accurately as you know it - e.g. "1996", "Mar 2010")')
		self.fields['types'] = ProductionTypeMultipleChoiceField(required=False, label='Type',
			queryset=ProductionType.featured_types())
		self.fields['platforms'] = forms.ModelMultipleChoiceField(required=False, label='Platform',
			queryset=Platform.objects.all())
Пример #5
0
	def __init__(self, *args, **kwargs):
		self.types_to_set = kwargs.pop('types_to_set', [])
		self.show_production_type_field = kwargs.pop('show_production_type_field', False)
		self.byline_field = BylineField(required=False)
		supertype = kwargs.pop('supertype', None)
		self.widget = ProductionWidget(
			types_to_set=self.types_to_set,
			supertype=supertype,
			show_production_type_field=self.show_production_type_field,
		)

		super(ProductionField, self).__init__(*args, **kwargs)
Пример #6
0
class ProductionField(forms.Field):
	def __init__(self, *args, **kwargs):
		self.types_to_set = kwargs.pop('types_to_set', [])
		self.show_production_type_field = kwargs.pop('show_production_type_field', False)
		self.byline_field = BylineField(required=False)
		supertype = kwargs.pop('supertype', None)
		self.widget = ProductionWidget(
			types_to_set=self.types_to_set,
			supertype=supertype,
			show_production_type_field=self.show_production_type_field,
		)

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

	def clean(self, value):
		if not value:
			value = None
		else:
			value = ProductionSelection.from_value(value, types_to_set=self.types_to_set)
			value.byline = self.byline_field.clean(value.byline_lookup)

		return super(ProductionField, self).clean(value)