def test_get_context(self):
     dp_input = DatePickerInput()
     context = dp_input.get_context('input_name', '2018-04-12', {})
     self.assertEqual(context['widget']['name'], 'input_name')
     self.assertEqual(context['widget']['value'], '2018-04-12')
     self.assertEqual(context['widget']['attrs']['fp_config'],
                      dp_input.config.to_json())
예제 #2
0
class ToDoForm(forms.Form):
    start_date = forms.DateField(
        label="Start Date", widget=DatePickerInput().start_of('custom event'))
    end_date = forms.DateField(label="End Date",
                               widget=DatePickerInput().end_of('custom event'))
    message = forms.CharField(
        label="Message", widget=forms.Textarea(attrs={'class': 'textarea'}))
예제 #3
0
파일: forms.py 프로젝트: diegmore/iPPE
 class Meta:
     model = Equipment
     fields = [
         'code',
         'name',
         'description',
         'time_of_life',
         'manteinance_cleaning',
         'certification',
         'mode_use',
         'start_date',
         'end_date',
         'body_area',
         'element_classification',
         'work_activities',
     ]
     labels = {
         'code': 'Code',
         'name': 'Name',
         'description': 'Description',
         'time_of_life': 'Time of life',
         'manteinance_cleaning': 'Manteinance Cleaning',
         'certification': 'Certification',
         'mode_use': 'Mode Use',
         'start_date': 'Start Date',
         'end_date': 'End Date',
         'body_area': 'Body Area',
         'element_classification': 'Element Classification',
         'work_activities': 'Work Activities',
     }
     widgets = {
         'code':
         forms.TextInput(attrs={'class': 'form-control'}),
         'name':
         forms.TextInput(attrs={'class': 'form-control'}),
         'description':
         forms.Textarea(attrs={'class': 'form-control'}),
         'manteinance_cleaning':
         forms.TextInput(attrs={'class': 'form-control'}),
         'certification':
         forms.TextInput(attrs={'class': 'form-control'}),
         'mode_use':
         forms.TextInput(attrs={'class': 'form-control'}),
         'time_of_life':
         forms.TextInput(attrs={'class': 'form-control'}),
         'start_date':
         DatePickerInput(),
         'end_date':
         DatePickerInput(),
         'body_area':
         forms.Select(attrs={'class': 'form-control'}),
         'element_classification':
         forms.Select(attrs={'class': 'form-control'}),
         'work_activities':
         forms.Select(attrs={
             'class': 'form-control wa-tags',
             'multiple': 'multiple'
         }),
     }
예제 #4
0
 class Meta:
     model = ApplicantExam
     fields = (
         'applicant',
         'exam',
         'exam_Date',
         'expire_Date',
         'score',
     )
     widgets = {
         'exam_Date': DatePickerInput(),
         'expire_Date': DatePickerInput(),
     }
예제 #5
0
    class Meta:
        model = models.ProjectModel
        fields = '__all__'
        widgets = {
            'id_employee': autocomplete.ModelSelect2Multiple(
                url='user_autocomplete',
                attrs={
                    'data-minimum-input-length': 3,
                    },
                ),

            'start_date': DatePickerInput(options = { "dateFormat": "d.m.y",}),
            'end_date': DatePickerInput(options = { "dateFormat": "d.m.y",}),
        }
예제 #6
0
 class Meta:
     model = models.ResourceModel
     fields = ['name', 'production_year', 'resource_state', 'image', 'brand', 'model', 'info', 'is_available']
     widgets = {
         'approver_user': autocomplete.ModelSelect2(
             url='user_admin_autocomplete',
             attrs={
                 'data-minimum-input-length': 3,
                 },
             ),
         
         'production_year': DatePickerInput(options = { "dateFormat": "d.m.y",}),
         'start_date': DatePickerInput(options = { "dateFormat": "d.m.y",}),
         'end_date': DatePickerInput(options = { "dateFormat": "d.m.y",}),
     }
예제 #7
0
class ProjectForm(forms.Form):
    title = forms.CharField(label = 'Working or Lay Title')
    research_topic = forms.CharField()
    irb = forms.CharField(label = 'IRB# (or PRE#)', max_length=25, widget=forms.TextInput(attrs={'placeholder': '##-######'}))
    irb_approved = forms.BooleanField(label = 'IRB approved', required=False)
    description = forms.CharField(label = 'Please provide the research question for this project.', max_length=200) 
    investigator = forms.CharField(label = 'Principal Investigator Name', max_length=100)
    investigator_phone = forms.CharField(label = 'Principal Investigator Phone', max_length=100, widget=forms.TextInput(attrs={'placeholder': '###-###-####'}))
    investigator_email = forms.CharField(label = 'Principal Investigator Email', max_length=100, widget=forms.TextInput(attrs={'placeholder': 'Email'}))
    requestor = forms.CharField(label = 'Study Contact Name', max_length=100)
    requestor_phone = forms.CharField(label = 'Study Contact Phone', max_length=100, widget=forms.TextInput(attrs={'placeholder': '###-###-####'}))
    requestor_email = forms.EmailField(label = 'Study Contact Email', max_length=100, widget=forms.TextInput(attrs={'placeholder': 'Email'}))
    deadline_date = forms.DateField(label = 'Deadline for Obtaining Dataset', 
                                        widget=DatePickerInput())
    request_type = forms.ChoiceField(label = 'Request Type', widget=forms.RadioSelect(),
                                    choices=REQUEST_TYPE_CHOICES)
    intended_used = forms.ChoiceField(label = 'Intended Use of Counts or Dataset', 
                                    widget=forms.RadioSelect(),
                                    choices=INTENDED_USE_CHOICES
                                    )
    chart_review = forms.BooleanField(label = 'Chart Review', required=False)
    recruitment = forms.BooleanField(label = 'Recruitment Study', required=False)


    class Meta:
        model = Project
        fields = [  'title','irb','description','investigator','investigator_phone','investigator_email',
    'requestor','requestor_phone','requestor_email','chart_review',
    'request_type', 
    'date_deadline',
    ]
예제 #8
0
 class Meta:
     model = TimePost
     fields = (
         'date',
         'client',
         'project',
         'time_spent',
         'notes',
         'expenses',
         'expense_notes',
         'miles',
         'miles_notes',
     )
     widgets = {
         'notes': forms.Textarea(attrs={'rows': 2}),
         'date': DatePickerInput(),
         'miles_notes': forms.Textarea(attrs={'rows': 2}),
         'expense_notes': forms.Textarea(attrs={'rows': 2}),
     }
     help_texts = {
         'time_spent': '''This field is in hours.  
         Partial hours should only be entered as quarter-hours
         (.25, .5, .75, .0)''',
         'expense notes': '''  '''
     }
예제 #9
0
class ArchiveIssue(Page):
    publication_date = models.DateField(
        null=True,
        help_text="Please select the first day of the publication month")
    internet_archive_identifier = models.CharField(
        max_length=255,
        db_index=True,
        help_text="Identifier for Internet Archive item.",
        unique=True,
    )
    western_friend_volume = models.CharField(
        max_length=255,
        help_text="Related Western Friend volume.",
        null=True,
        blank=True,
    )
    table_of_contents = StreamField([("Article", ArchiveArticleBlock())],
                                    null=True,
                                    blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("publication_date", widget=DatePickerInput()),
        FieldPanel("internet_archive_identifier"),
        FieldPanel("western_friend_volume"),
        StreamFieldPanel("table_of_contents"),
    ]

    parent_page_types = ["DeepArchiveIndexPage"]
    subpage_types = []
예제 #10
0
 class Meta:
     model = Contact
     fields = [
         'first_name',
         'last_name',
         'birthday',
     ]
     widgets = {'birthday': DatePickerInput()}
예제 #11
0
class Memorial(Page):
    # TODO: use a relationship to the Contacts here
    # instead of storing given/family names in Memorial model
    given_name = models.CharField(
        max_length=255,
        default="",
        help_text="Enter the given name for a person.",
    )
    family_name = models.CharField(max_length=255, blank=True, default="")
    date_of_birth = models.DateField()
    date_of_death = models.DateField()
    dates_are_approximate = models.BooleanField()
    memorial_minute = RichTextField(blank=True)
    memorial_meeting = models.ForeignKey(
        to="contact.Meeting",
        on_delete=models.PROTECT,
        related_name="memorial_minutes"
    )

    def full_name(self):
        return f"{ self.given_name } { self.family_name }"

    content_panels = [
        FieldPanel("given_name"),
        FieldPanel("family_name"),
        FieldPanel("date_of_birth", widget=DatePickerInput()),
        FieldPanel("date_of_death", widget=DatePickerInput()),
        FieldPanel("dates_are_approximate"),
        FieldPanel("memorial_minute"),
        PageChooserPanel("memorial_meeting"),
    ]

    parent_page_types = [
        "memorials.MemorialIndexPage",
    ]

    def save(self, *args, **kwargs):
        self.title = self.full_name()

        super(Memorial, self).save(*args, **kwargs)

    search_fields = [
        index.SearchField("given_name", partial_match=True),
        index.SearchField("family_name", partial_match=True),
    ]
예제 #12
0
 class Meta:
     model = Event
     fields = [
         'start_date',
         'end_date',
         'start_time',
         'end_time',
         'start_datetime',
         'end_datetime',
     ]
     widgets = {
         'start_date': DatePickerInput().start_of('event active days'),
         'end_date': DatePickerInput().end_of('event active days'),
         'start_time': TimePickerInput().start_of('event active time'),
         'end_time': TimePickerInput().end_of('event active time'),
         'start_datetime': DateTimePickerInput().start_of('event datetime'),
         'end_datetime': DateTimePickerInput().end_of('event datetime'),
     }
예제 #13
0
 class Meta:
     model = Todo
     today = datetime.date.today()
     fields = ['caller', 'start_time', 'end_time', 'call_to', 'data']
     widgets = {
         'start_time': TimePickerInput().start_of('todo active time'),
         'end_time': TimePickerInput().end_of('todo active time'),
         'call_to': forms.SelectMultiple(attrs={'class': 'multiple', "size": "8"}),
         'data': DatePickerInput(options={"dateFormat": "d/m/Y", "defaultDate": "today"}),
     }
 class Meta:
     model = models.HolidayModel
     fields = '__all__'
     widgets = {
         'approver_user':
         autocomplete.ModelSelect2(
             url='user_admin_autocomplete',
             attrs={
                 'data-minimum-input-length': 3,
             },
         ),
         'start_date':
         DatePickerInput(options={
             "dateFormat": "d.m.y",
         }),
         'end_date':
         DatePickerInput(options={
             "dateFormat": "d.m.y",
         }),
     }
예제 #15
0
class BuscarEspecialidadForm(forms.Form):
    especialidad = forms.ModelChoiceField(
        queryset = Especialidad.objects.all(),
        required = True,
    )
    fecha = forms.DateField(widget=DatePickerInput(
        options = {  
            # flatpickr options
            "dateFormat": "d/m/Y",
            "minDate": str(datetime.date.today()),
        }).start_of(datetime.date.today())
    )
예제 #16
0
 class Meta:
     model = Pedidos
     fields = ['fecha', 'client', 'comentario', 'direnvio']
     widgets = {
         'fecha':
         DatePickerInput(options={"disableMobile": "true"},
                         attrs={'stlye': 'margin-top:20px;'}),
         'comentario':
         forms.Textarea(attrs={'rows': 5}),
         'direnvio':
         forms.Textarea(attrs={'rows': 1}),
     }
예제 #17
0
 class Meta:
     model = BookInstance
     fields = ['due_back']
     help_texts = {
         'due_back': _('Enter a date between now and 4 weeks (default 3).'),
     }
     labels = {
         'due_back': _('Renewal Date:'),
     }
     widgets = {
         'due_back': DatePickerInput(),
     }
예제 #18
0
 class Meta:
     model = Sleeptime
     fields = ('create_date', 'sleep_at', 'wakeup_at')
     widgets = {
         'create_date':
         DatePickerInput(options={
             'locale': 'ja',
             'dayViewHeaderFormat': 'YYYY年 MMMM',
         }),
         'sleep_at':
         TimePickerInput(),
         'wakeup_at':
         TimePickerInput()
     }
예제 #19
0
 class Meta:
     model = Gastos
     fields = ['cantidades', 'total_gasto', 'gasto', 'fechacarga']
     widgets = {
         'cantidades': forms.Textarea(attrs={
             'cols': 3,
             'rows': 1
         }),
         'total_gasto': forms.Textarea(attrs={
             'cols': 8,
             'rows': 1
         }),
         'fechacarga': DatePickerInput(options={"disableMobile": "true"})
     }
예제 #20
0
class CreateView(GenericViewWidgetMixin, generic.edit.CreateView):
    model = Event
    fields = [
        'start_date',
        'end_date',
        'start_time',
        'end_time',
        'start_datetime',
        'end_datetime',
    ]
    widgets = {
        'start_date': DatePickerInput().start_of('event days'),
        'end_date': DatePickerInput().end_of('event days'),
        'start_time': TimePickerInput().start_of('event time'),
        'end_time': TimePickerInput().end_of('event time'),
        'start_datetime': DateTimePickerInput().start_of('event dtime'),
        'end_datetime': DateTimePickerInput().end_of('event dtime'),
    }

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['title_text'] = 'Generic View without using model form'
        context['submit_text'] = 'Create Event'
        return context
예제 #21
0
class MagazineIssue(Page):
    cover_image = models.ForeignKey(
        "wagtailimages.Image",
        on_delete=models.SET_NULL,
        null=True,
        blank=True,
        related_name="+",
    )
    publication_date = models.DateField(
        null=True,
        help_text="Please select the first day of the publication month")
    issue_number = models.PositiveIntegerField(null=True, blank=True)

    @property
    def publication_end_date(self):
        if self.publication_date:
            # TODO: try to find a cleaner way to add a month to the publication date
            # I.e. the 'add a month' approach may be flawed altogether.
            return self.publication_date + timedelta(days=+31)

    search_template = "search/magazine_issue.html"

    content_panels = Page.content_panels + [
        FieldPanel("publication_date", widget=DatePickerInput()),
        ImageChooserPanel("cover_image"),
        InlinePanel(
            "featured_articles",
            heading="Featured articles",
            help_text="Select one or more featured articles, from this issue",
        ),
    ]

    parent_page_types = ["MagazineIndexPage"]
    subpage_types = ["MagazineArticle"]

    def get_context(self, request, *args, **kwargs):
        context = super().get_context(request)
        context["articles_by_department"] = (MagazineArticle.objects.child_of(
            self).live().order_by("department__title"))

        return context

    def get_sitemap_urls(self):
        return [{
            "location": self.full_url,
            "lastmod": self.latest_revision_created_at
        }]
예제 #22
0
class LibraryItem(Page):
    publication_date = models.DateField("Publication date")
    body = StreamField([
        ("paragraph", blocks.RichTextBlock()),
        ("image", ImageChooserBlock()),
        ("document", DocumentChooserBlock()),
        ("embed", EmbedBlock()),
        ("url", blocks.URLBlock()),
        ("quote", blocks.BlockQuoteBlock()),
    ])
    item_audience = models.ForeignKey("facets.Audience",
                                      on_delete=models.SET_NULL,
                                      null=True)
    item_genre = models.ForeignKey("facets.Genre",
                                   on_delete=models.SET_NULL,
                                   null=True)
    item_medium = models.ForeignKey("facets.Medium",
                                    on_delete=models.SET_NULL,
                                    null=True)
    item_time_period = models.ForeignKey("facets.TimePeriod",
                                         on_delete=models.SET_NULL,
                                         null=True)

    content_panels = Page.content_panels + [
        InlinePanel(
            "authors",
            heading="Authors",
            help_text=
            "Select one or more authors, who contributed to this article",
        ),
        FieldPanel("publication_date", widget=DatePickerInput()),
        StreamFieldPanel("body"),
        MultiFieldPanel(
            children=[
                FieldPanel("item_audience"),
                FieldPanel("item_genre"),
                FieldPanel("item_medium"),
                FieldPanel("item_time_period"),
                InlinePanel("topics", label="topics")
            ],
            heading="Categorization",
        ),
    ]

    parent_page_types = ["LibraryIndexPage"]
    subpage_types = []
예제 #23
0
class AddressForm(forms.Form):
    title = forms.CharField()
    irb = forms.CharField(
        max_length=25,
        widget=forms.TextInput(attrs={'placeholder': '##-######'}))
    description = forms.CharField(max_length=200)
    investigator = forms.CharField(max_length=100)
    investigator_phone = forms.CharField(
        max_length=100,
        widget=forms.TextInput(attrs={'placeholder': '###-###-####'}))
    investigator_email = forms.CharField(
        max_length=100, widget=forms.TextInput(attrs={'placeholder': 'Email'}))
    requestor = forms.CharField(max_length=100)
    requestor_phone = forms.CharField(
        max_length=100,
        widget=forms.TextInput(attrs={'placeholder': '###-###-####'}))
    requestor_email = forms.EmailField(
        max_length=100, widget=forms.TextInput(attrs={'placeholder': 'Email'}))
    deadline_date = forms.DateField(widget=DatePickerInput())
    # email = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Email'}))
    # password = forms.CharField(widget=forms.PasswordInput())
    # address_1 = forms.CharField(label='Address', widget=forms.TextInput(attrs={'placeholder': '1234 Main St'}))
    # address_2 = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Apartment, studio, or floor'}))
    # city = forms.CharField()
    request_type = forms.ChoiceField(choices=REQUEST_TYPE_CHOICES)
    chart_review = forms.BooleanField(required=False)

    class Meta:
        model = Project
        fields = [
            'title',
            'irb',
            'description',
            'investigator',
            'investigator_phone',
            'investigator_email',
            'requestor',
            'requestor_phone',
            'requestor_email',
            'chart_review',
            'request_type',
            'date_deadline',
        ]
예제 #24
0
파일: forms.py 프로젝트: lawalkeyd/EasyBuy
 class Meta:
     model = Product
     fields = '__all__'
     widgets = {
         'title':
         forms.TextInput(attrs={'class': 'form-control'}),
         'category':
         forms.Select(attrs={'class': 'form-control'}),
         'price':
         forms.NumberInput(attrs={'class': 'form-control'}),
         'discount_price':
         forms.NumberInput(attrs={'class': 'form-control'}),
         'photo':
         forms.FileInput(attrs={'class': 'form-control'}),
         'description':
         forms.TextInput(attrs={'class': 'form-control'}),
         'label':
         forms.Select(attrs={'class': 'form-control'}),
         'next_available_date':
         DatePickerInput(attrs={'class': 'form-control'}),
     }
예제 #25
0
class ArchiveIssue(Page):
    internet_archive_identifier = models.CharField(
        max_length=255,
        db_index=True,
        help_text="Identifier for Internet Archive item.",
        unique=True,
    )
    western_friend_volume = models.CharField(
        max_length=255, help_text="Related Western Friend volume.")

    content_panels = Page.content_panels + [
        FieldPanel("internet_archive_identifier"),
        FieldPanel("western_friend_volume"),
        FieldPanel("first_published_at", widget=DatePickerInput()),
        StreamFieldPanel("table_of_contents")
    ]

    parent_page_types = ["DeepArchiveIndexPage"]
    table_of_contents = StreamField([
        ("Article", ArchiveArticleBlock()),
    ],
                                    null=True,
                                    blank=True)
예제 #26
0
class RenewBookForm(forms.Form):
    renewal_date = forms.DateField(
        widget=DatePickerInput(),
        help_text='Enter a date between today and 4 weeks later (default 3).',
    )

    renewal_date.widget.attrs.update({
        'class': 'date date-field',
        'id': 'renewal-date'
    })

    def clean_renewal_date(self):
        data = self.cleaned_data['renewal_date']
        is_in_past = False
        # check if the date is not in the past
        if data < datetime.date.today():
            is_in_past = True
            raise ValidationError(_('Invalid date - date in the past.'))
        # check if the date is not 4 weeks far
        if data > datetime.date.today() + datetime.timedelta(weeks=4):
            raise ValidationError(
                _('Invalid date - date is more than 4 weeks ahead.'))

        return data
예제 #27
0
 def test_dateformat_override(self):
     widget = DatePickerInput(options={'dateFormat': 'my_format'})
     self.assertEqual(widget.config.options['altFormat'], 'my_format')
     self.assertEqual(widget.config.options['dateFormat'],
                      DatePickerInput.option_overrides['dateFormat'])
예제 #28
0
 class Meta:
     model = Task
     fields = '__all__'
     widgets = {
         'due_date': DatePickerInput(),
     }
예제 #29
0
class Subscription(models.Model):
    format = models.CharField(max_length=255,
                              choices=MAGAZINE_FORMAT_CHOICES,
                              default="pdf")
    price_group = models.CharField(max_length=255,
                                   choices=MAGAZINE_PRICE_GROUP_CHOICES,
                                   default="normal")
    price = models.IntegerField(editable=False)
    recurring = models.BooleanField(default=True)
    start_date = models.DateField(null=True)
    end_date = models.DateField(null=True)
    subscriber_given_name = models.CharField(
        max_length=255,
        default="",
        help_text="Enter the given (first) name for the subscriber.",
    )
    subscriber_family_name = models.CharField(
        max_length=255,
        default="",
        help_text="Enter the family (last) name for the subscriber.",
    )
    subscriber_organization = models.CharField(max_length=255,
                                               null=True,
                                               blank=True)
    subscriber_street_address = models.CharField(
        max_length=255,
        blank=True,
        default="",
        help_text=
        "The street address where a print subscription could be mailed.",
    )
    subscriber_street_address_line_2 = models.CharField(
        max_length=255,
        blank=True,
        default="",
        help_text="If needed, second line for mailing address.",
    )
    subscriber_postal_code = models.CharField(
        max_length=16,
        help_text="Postal code for the mailing address.",
        blank=True,
    )
    subscriber_address_locality = models.CharField(
        max_length=255,
        help_text="City for the mailing address.",
        blank=True,
    )
    subscriber_address_region = models.CharField(
        max_length=255,
        help_text="State for the mailing address.",
        blank=True,
        default="",
    )
    subscriber_address_country = models.CharField(
        max_length=255,
        default="United States",
        help_text="Country for mailing.",
        blank=True,
    )

    user = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        verbose_name="subscriber email",
        # TODO: determine whether we want these to be nullable
        # e.g. for tracking subscriptions created offline
        # null=True,
        # blank=True,
        editable=True,
        on_delete=models.PROTECT,
        related_name="subscriptions",
    )

    paid = models.BooleanField(default=False)

    braintree_subscription_id = models.CharField(
        max_length=255,
        blank=True,
        help_text=
        "DO NOT EDIT. Used to cross-reference subscriptions with Braintree payments.",
    )

    panels = [
        FieldPanel("user"),
        FieldPanel("subscriber_given_name"),
        FieldPanel("subscriber_family_name"),
        FieldPanel("subscriber_street_address"),
        FieldPanel("subscriber_street_address_line_2"),
        FieldPanel("subscriber_postal_code"),
        FieldPanel("subscriber_address_locality"),
        FieldPanel("subscriber_address_region"),
        FieldPanel("subscriber_address_country"),
        FieldPanel("start_date", widget=DatePickerInput()),
        FieldPanel("end_date", widget=DatePickerInput()),
        FieldPanel("paid"),
        FieldPanel("braintree_subscription_id"),
    ]

    def __str__(self):
        return f"subscription {self.id}"

    @property
    def subscriber_full_name(self):
        full_name = ""

        if self.subscriber_given_name:
            full_name += self.subscriber_given_name + " "
        if self.subscriber_family_name:
            full_name += self.subscriber_family_name + " "

        return full_name.rstrip()

    def get_total_cost(self):
        return self.price

    def save(self, *args, **kwargs):
        self.price = SUBSCRIPTION_PRICE_COMPONENTS[self.price_group][
            self.format]

        super().save(*args, **kwargs)
예제 #30
0
 class Meta:
     model = Expense
     fields = ['category', 'description', 'cost']
     widgets = {
         'date': DatePickerInput(),
     }