Example #1
0
class PageTemplateForm(forms.Form):

    name = forms.CharField(
        label='Name',
        widget=forms.TextInput(attrs={'class': 'name-validation'}),
        max_length=100,
        required=True)

    footer = forms.CharField(label='Page Footer',
                             widget=forms.Textarea(),
                             max_length=30000,
                             required=False)

    default = forms.BooleanField(label='Default Template?', required=False)

    backgroundImageID = forms.UUIDField(label='Background Image',
                                        widget=ImageSelect,
                                        required=False)

    logoImageID = forms.UUIDField(label='Company Logo',
                                  widget=ImageSelect,
                                  required=False)

    def __init__(self, *args, **kwargs):

        backgroundImageID = kwargs.pop('backgroundImageID', '')
        logoImageID = kwargs.pop('logoImageID', '')
        super().__init__(*args, **kwargs)
        self.fields['backgroundImageID'].widget = ImageSelect(
            imageID=backgroundImageID, name='backgroundImageID')
        self.fields['logoImageID'].widget = ImageSelect(imageID=logoImageID,
                                                        name='logoImageID')
Example #2
0
class InvitationCreateForm(ModelForm):
    user_uuid = forms.UUIDField(widget = forms.HiddenInput(),required=True)
    position_uuid = forms.UUIDField(widget = forms.HiddenInput(), required=True)
    application = forms.IntegerField(widget = forms.HiddenInput(), required=True)
    interview_time = forms.DateTimeField(required=True)
    class Meta:
        model= Invitation
        fields = (
            'interview_time',
            'interview_address',
            'content',
        )
Example #3
0
class AllocationForm(forms.Form):
    warehouse = forms.ModelChoiceField(queryset=Warehouse.objects.all())
    stock = forms.UUIDField(widget=forms.HiddenInput())
    order_line = forms.UUIDField(widget=forms.HiddenInput())
    quantity = forms.IntegerField()

    def save(self):
        stock = Stock.objects.get(guid=self.cleaned_data["stock"])
        stock.allocate_to_order_line_item(
            line_item=LineItem.objects.get(
                guid=self.cleaned_data["order_line"]),
            quantity=self.cleaned_data["quantity"],
        )
Example #4
0
class UUIDField(forms.Form):
    description = "UUIDField options"

    field1 = forms.UUIDField(help_text='default')
    field2 = forms.UUIDField(help_text='initial value', initial=uuid.uuid4())
    field3 = forms.UUIDField(help_text='prefix')
    field4 = forms.UUIDField(help_text='disabled',
                             disabled=True,
                             required=False)

    template = Template("""
    {% form %}
        {% part form.field3 prefix %}<i class="material-icons prefix">insert_invitation</i>{% endpart %}
    {% endform %}
    """)
Example #5
0
class ExperienceForm(forms.ModelForm):
    work_history_id = forms.UUIDField(required=False, )

    class Meta:
        model = Experience
        fields = ('work_history_id', 'organization', 'job', 'experience',
                  'from_date', 'to_date')
class CreateTournament(forms.ModelForm):
    tournament_date = forms.DateField(required=False)
    tournament_time = forms.TimeField(required=False)
    picture = forms.ImageField(required=False)
    center = forms.UUIDField(required=False)
    format = forms.UUIDField(required=False)
    entry_fee = forms.FloatField(required=False)
    total_games = forms.IntegerField(required=False)
    placements = forms.JSONField(required=False)
    class Meta:
        model = Tournament
        fields = ['name', 'description', 'datetime', 'picture', 'center', 'format', 'entry_fee', 'total_games', 'placements']

    def clean(self):
        cleaned_data = super().clean()
        return cleaned_data
Example #7
0
class FromRegister(forms.Form):
    """
        check image code
    """
    mobile = forms.CharField(max_length=11, min_length=11, validators=[mobile_validator, ],
                             error_messages={"min_length": "手机号长度有误", "max_length": "手机号长度有误",
                                             "required": "手机号不能为空"})
    image_code_id = forms.UUIDField(error_messages={"required": "图片UUID不能为空"})
    text = forms.CharField(max_length=4, min_length=4,
                           error_messages={"min_length": "图片验证码长度有误", "max_length": "图片验证码长度有误",
                                           "required": "图片验证码不能为空"})

    def clean(self):
        # 继承父类clean 方法   复用校验
        cleaned_data = super().clean()
        mobile_num = cleaned_data.get('mobile')
        image_uuid = cleaned_data.get('image_code_id')
        image_text = cleaned_data.get('text')

        # 1、获取图片验证码
        con_redis = get_redis_connection(alias='verify_codes')
        img_key = "img_{}".format(image_uuid).encode('utf-8')
        redis_img_code = con_redis.get(img_key)  # b'ABCD'  # False

        # 校验
        real_image_code = redis_img_code.decode('utf8') if redis_img_code else None

        # 2、判断用户输入的图片验证码与数据库取得是否一致
        if image_text.upper() != real_image_code:
            raise forms.ValidationError("图片验证码校验失败")

        # 3、判断在60秒内是否有发送短信的记录
        if con_redis.get("sms_flag_{}".format(mobile_num)):
            raise forms.ValidationError("获取短信验证码过于频繁")
        return cleaned_data
Example #8
0
class SubscriptionPlanCostForm(forms.Form):
    """Form to handle choosing a subscription plan for payment."""
    plan_cost = forms.UUIDField(label='Choose subscription',
                                widget=forms.RadioSelect())

    def __init__(self, *args, **kwargs):
        """Overrides the plan_cost widget with available selections.

            For a provided subscription plan, provides a widget that
            lists all possible plan costs for selection.

            Keyword Arguments:
                subscription_plan (obj): A SubscriptionPlan instance.
        """
        costs = kwargs.pop('subscription_plan').costs.all()
        PLAN_COST_CHOICES = []

        for cost in costs:
            radio_text = '{} {}'.format(
                CURRENCY[SETTINGS['currency_locale']].format_currency(
                    cost.cost), cost.display_billing_frequency_text)
            PLAN_COST_CHOICES.append((cost.id, radio_text))

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

        # Update the radio widget with proper choices
        self.fields['plan_cost'].widget.choices = PLAN_COST_CHOICES
Example #9
0
class ManyFieldsExampleForm(forms.Form):
	hiddeninput = forms.CharField(widget=forms.HiddenInput())
	multiplehiddeninput = forms.MultipleChoiceField(widget=forms.MultipleHiddenInput, choices=CONTINENTS)
	modelchoicefield = forms.ModelChoiceField(queryset=Friend.objects.all(), empty_label="Empty Space", to_field_name="first_name")
	modelchoicefield2 = forms.ModelChoiceField(queryset=Friend.objects.all(), to_field_name="first_name")
	modelmultiplechoicefield = forms.ModelMultipleChoiceField(queryset=Friend.objects.all())
	booleanfield = forms.BooleanField(label="BooleanField")
	charfield = forms.CharField(label="CharField")
	choicefield = forms.ChoiceField(label="ChoiceField", choices=CONTINENTS)
	typedchoicefield = forms.TypedChoiceField(label="TypedChoiceField")
	datefield = forms.DateField(label="DateField")
	datetimefield = forms.DateTimeField(label="DateTimeField")
	decimalfield = forms.DecimalField(label="DecimalField")
	durationfield = forms.DurationField(label="DurationField")
	emailfield = forms.EmailField(label="EmailField")
	filefield = forms.FileField(label="FileField")
	filepathfield = forms.FilePathField(label="FilePathField", path="/")
	floatfield = forms.FloatField(label="FloatField")
	imagefield = forms.ImageField(label="ImageField")
	integerfield = forms.IntegerField(label="IntegerField")
	genericipaddressfield = forms.GenericIPAddressField(label="GenericIPAddressField")
	multiplechoicefield = forms.MultipleChoiceField(label="MultipleChoiceField", choices=CONTINENTS)
	typedmultiplechoicefield = forms.TypedMultipleChoiceField(label="TypedMultipleChoiceField", choices=CONTINENTS)
	nullbooleanfield = forms.NullBooleanField(label="NullBooleanField")
	slugfield = forms.SlugField(label="SlugField")
	timefield = forms.TimeField(label="TimeField")
	urlfield = forms.URLField(label="URLField")
	uuidfield = forms.UUIDField(label="UUIDField")
Example #10
0
class ProactiveEngagementFindingForm(EngagementFindingForm, ProactiveForm):

    findingGroup = forms.UUIDField(label='Finding Group', required=True)
    field_order = [
        'name', 'findingGroup', 'categoryID', 'description',
        'affectedResources', 'background', 'references'
    ]
Example #11
0
class FindingForm(forms.Form):

    # override in child class
    scoringType = 'None'

    # Common fields across all findings
    name = forms.CharField(
        label='Finding Name',
        widget=forms.TextInput(attrs={'class': 'name-validation'}),
        max_length=100)
    background = forms.CharField(label='Background',
                                 widget=forms.Textarea(),
                                 max_length=30000,
                                 required=False)
    remediation = forms.CharField(label='Remediation',
                                  widget=forms.Textarea(),
                                  max_length=30000,
                                  required=False)
    references = forms.CharField(label='References',
                                 widget=forms.Textarea(),
                                 max_length=30000,
                                 required=False)

    categoryID = forms.UUIDField(
        label='Category',
        widget=CategoryBootstrapSelectEngagements(attrs={'required': 'true'}),
        required=True)

    @property
    def className(self):

        return type(self).__name__
Example #12
0
class TestFileForm(forms.Form):

    bridge_artifact = forms.ModelChoiceField(queryset=models.MajoraArtifact.objects.all(), required=False, to_field_name="dice_name")
    source_artifact = forms.ModelMultipleChoiceField(queryset=models.MajoraArtifact.objects.all(), required=False, to_field_name="dice_name")
    source_group = forms.ModelMultipleChoiceField(queryset=models.MajoraArtifactGroup.objects.all(), required=False, to_field_name="dice_name")
    publish_group = forms.CharField(max_length=128, required=False)

    #pipe_id = forms.UUIDField()
    pipe_hook = forms.CharField(max_length=256)
    artifact_uuid = forms.UUIDField(required=False)
    pipe_kind = forms.CharField(max_length=64)
    pipe_name = forms.CharField(max_length=96)
    pipe_version = forms.CharField(max_length=48)

    #node_uuid = forms.ModelChoiceField(queryset=models.DigitalResourceNode.objects.all())
    node_name = forms.ModelChoiceField(queryset=models.DigitalResourceNode.objects.all(), to_field_name="unique_name", required=False)
    path = forms.CharField(max_length=1024)
    sep = forms.CharField(max_length=2)
    current_name = forms.CharField(max_length=512)
    current_fext = forms.CharField(max_length=48)

    current_hash = forms.CharField(max_length=64)
    current_size = forms.IntegerField(min_value=0)

    resource_type = forms.ChoiceField(
        choices= [
            ("file", "file"),
            ("reads", "reads"),
            ("alignment", "alignment"),
            ("consensus", "consensus"),
        ],
    )
Example #13
0
class ReplyForm(forms.ModelForm):
    text = forms.CharField(
        label="Ответ",
        required=True,
        max_length=10000,
        widget=forms.Textarea(
            attrs={
                "maxlength": 10000,
                "placeholder": "Напишите ответ...",
                "class": "markdown-editor-invisible",
            }),
    )
    reply_to_id = forms.UUIDField(label="Ответ на", required=True)

    class Meta:
        model = Comment
        fields = [
            "text",
            # "reply_to"
        ]

    def clean(self):
        cleaned_data = super().clean()

        try:
            self.instance.reply_to = Comment.objects.get(
                id=cleaned_data["reply_to_id"])
        except Comment.DoesNotExist:
            raise ValidationError("Ответ на неизвестный коммент")

        return cleaned_data
Example #14
0
class EducationForm(forms.ModelForm):
    educational_bg_id = forms.UUIDField(required=False, )

    class Meta:
        model = Education
        fields = ('educational_bg_id', 'school', 'major', 'graduated_at',
                  'detail')
Example #15
0
class PackageIntegrationForm(forms.Form):
    token = forms.UUIDField(required=True)
    run_id = forms.CharField(required=True)
    version = forms.CharField(required=True)
    package_name = forms.CharField(required=True)
    repository = forms.CharField(required=True)

    def is_known(self):
        try:
            package = Package.objects.get(token=self.cleaned_data['token'])

            config = {
                'package_id':
                package.pk,
                'run_id':
                self.cleaned_data['run_id'],
                'version':
                self.cleaned_data['version'],
                'package_name':
                self.cleaned_data['package_name'],
                'repository':
                self.cleaned_data['repository'],
                'github_token':
                conf.settings.GITHUB_TOKEN,
                'channel':
                os.path.join(conf.settings.CONDA_ASSET_PATH, 'qiime2',
                             'unverified'),
                'channel_name':
                'qiime2/unverified',
            }
        except Package.DoesNotExist:
            config = None

        return config
Example #16
0
class CreateCustodianFromPerson(forms.Form):
    person = forms.UUIDField(label=_('Selecciona persona'), required=False)
    category = forms.ChoiceField(label=_('Tipo'),
                                 choices=models.Custodian.CATEGORIES,
                                 required=False)

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

    def clean_person(self):
        person_uuid = self.cleaned_data['person']
        if not person_uuid:
            return
        try:
            person = models.Person.objects.get(pk=person_uuid)
        except models.Person.DoesNotExist:
            return
        return person

    def save(self):
        person = self.cleaned_data['person']
        category = self.cleaned_data['category']
        if not person:
            return
        custodian, __ = models.Custodian.objects.update_or_create(
            person=person, minor=self.minor, defaults={'category': category})
        return custodian
Example #17
0
class ApiForm(forms.Form):
	""" Used to validate the data from the form """

	data = forms.CharField(
		required=True,
		max_length=128,
		help_text="Data is to tell the server what data it's looking for",
		label="Data",
		error_messages={
			"required": "Please provide 'data' type you looking for.",
			"max_length": "Data is too long to be valid.",
			"invalid": "Data is invalid."
		}
	)

	q = forms.UUIDField(required=False)

	code = forms.CharField(
		required=False,
		max_length=128,
		label="Coupon Code",
		error_messages={
			"invalid": "Coupon Code invalid. Please try another one",
			"max_length": "Coupon Code is too long to be a valid code. Please try another one."
		}
	)
Example #18
0
class InviteForm(forms.Form):
    company_uuid = forms.UUIDField(required=True)
    emails = MultiEmailField(required=True)

    def clean(self):
        cleaned_data = super().clean()
        get_object_or_404(Company, uuid=cleaned_data.get('company_uuid'))
        return cleaned_data
Example #19
0
class UserActivationForm(forms.Form):
    token = forms.CharField(required=True)
    uuid = forms.UUIDField(required=True)

    def save(self, *args, **kwargs):
        user = User.objects.get(uuid=self.cleaned_data['uuid'])
        user.activate(self.cleaned_data['token'])
        return user
Example #20
0
class FindingImportForm(forms.Form):

    def __init__(self, *args, **kwargs):
        scoringType = kwargs.pop('scoringType') 
        super(FindingImportForm, self).__init__(*args, **kwargs)
        self.fields['finding'].widget = FindingBootstrapSelect(scoringType=scoringType)

    finding = forms.UUIDField(label='Finding')
Example #21
0
class UrlForm(forms.ModelForm):
    related_link_id = forms.UUIDField(required=False, )

    class Meta:
        model = Url
        fields = (
            'related_link_id',
            'url',
        )
Example #22
0
class JoinTeamForm(forms.ModelForm):
    token = forms.UUIDField(widget=forms.TextInput(attrs={
        'placeholder': 'token',
        'class': 'form-control'
    }), )

    class Meta:
        model = Team
        fields = ['token']
Example #23
0
class CategoryAddForm(forms.Form):

    categoryAddName = forms.CharField(
        label='Category Name',
        widget=forms.TextInput(attrs={'class': 'name-validation', 'required': 'true'}),
        max_length=1000)
    categoryAddID = forms.UUIDField(
        label='Parent Category',
        widget=CategoryBootstrapSelect)
Example #24
0
class AddonRecommendationsForm(forms.Form):
    client_id = forms.UUIDField(
        widget=forms.TextInput(attrs={'class': 'form-control'}), required=True)
    num_items = forms.IntegerField(
        widget=forms.NumberInput(attrs={'class': 'form-control'}),
        min_value=1,
        max_value=50,
        initial=10,
        required=True)
Example #25
0
class reportForm(forms.Form):

    name = forms.CharField(
        label='Title',
        widget=forms.TextInput(attrs={'class': 'name-validation'}),
        max_length=100)

    pageTemplateID = forms.UUIDField(label='Page Template',
                                     widget=PageTemplateSelect())
Example #26
0
class GeoPostForm(forms.Form):
    """
    Form for GeoPost model.
    """
    uuid = forms.UUIDField()
    title = forms.CharField(max_length=30)
    body = forms.CharField()
    wfsxml = forms.CharField()
    photo = forms.ImageField()
Example #27
0
class ReadingForm(forms.ModelForm):
    channel_uuid = forms.UUIDField()
    # reading = forms.FloatField()
    api_key = forms.CharField()

    # added = forms.DateTimeField()

    class Meta:
        model = Reading
        fields = ['value']
Example #28
0
class ResultRetrievalForm(forms.Form):
    sequence_id = forms.UUIDField(
        required=True,
        widget=forms.TextInput(
            attrs={
                "class": "input inputText is-fullwidth",
                "placeholder": "Sequence ID to retrieve results",
                "name": "sequenceID",
                "size": "36"
            }))
Example #29
0
class FSMSDRForm(forms.Form):
    uuid = forms.UUIDField(
        widget=forms.TextInput(attrs={'required': True}))
    delivery_on = forms.DateTimeField()
    status = forms.ChoiceField(
        choices=[(k, k) for k in SMSMessage.DELIVERY_STATUS_MATRIX.keys()])

    @classmethod
    def get_initial(cls):
        return {'delivery_on': timezone.now()}
Example #30
0
class SubscribeForm(forms.Form):
    interval = forms.DurationField(required=True)
    categories = forms.MultipleChoiceField(required=True)
    email = forms.EmailField(required=False)
    device = forms.UUIDField(required=False)

    def __init__(self, *args, **kwargs):
        self.category_choices = kwargs.pop('category_choices')
        super(SubscribeForm, self).__init__(*args, **kwargs)
        self.fields['categories'].choices = self.category_choices