Esempio n. 1
0
 class Meta:
     model = Competition
     exclude = ['questionsets']
     widgets = {
         'start': widgets.AdminDateWidget(),
         'end': widgets.AdminDateWidget(),
     }
class SubscriptionPreviewForm(forms.Form):
    center = forms.PointField(
        help_text="With the radius, determines the notification area.",
        srid=4326)
    radius = DistanceField(min_value=D(ft=100),
                           max_value=D(mi=1),
                           initial=D(ft=300))
    region_name = forms.ChoiceField(choices=(("Somerville, MA",
                                              "Somerville, MA"), ),
                                    initial=settings.GEO_REGION)
    start = forms.DateTimeField(widget=admin_widgets.AdminDateWidget(),
                                help_text="Find changes since this date")
    end = forms.DateTimeField(widget=admin_widgets.AdminDateWidget(),
                              help_text="Find changes up to this date")

    class Media:
        js = js_files()

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

        if cleaned["start"] >= cleaned["end"]:
            self.add_error("start",
                           ValidationError("start should be less than end"))
            self.add_error("end",
                           ValidationError("end should be greater than start"))

        try:
            center = cleaned["center"]
            cleaned["address"] = Geocoder.reverse_geocode(
                center.y, center.x).split(",")[0]
        except:
            cleaned["address"] = None

        return cleaned
Esempio n. 3
0
class FlightForm(forms.ModelForm):

    purchased = forms.DateField(widget=widgets.AdminDateWidget(),
                                localize=False,
                                required=False)
    date = forms.DateField(widget=widgets.AdminDateWidget(), localize=False)
    time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'),
                           input_formats=['%H:%M'],
                           required=False)

    field_order = [
        'travel', 'date', 'time', 'orig', 'dest', 'airline', 'flight_number',
        'plane', 'registration', 'seat', 'distance', 'duration', 'currency',
        'price', 'purchased', 'note'
    ]

    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'})
        }

    class Media:
        js = ('admin/js/vendor/jquery/jquery.js', 'admin/js/core.js')
        css = {'all': ('admin/css/forms.css', )}
Esempio n. 4
0
class JourneyForm(forms.ModelForm):

    start_date = forms.DateField(widget=widgets.AdminDateWidget(),
                                 localize=False)
    end_date = forms.DateField(widget=widgets.AdminDateWidget(),
                               localize=False,
                               required=False)
    start_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'),
                                 input_formats=['%H:%M'],
                                 required=False)
    notes = forms.CharField(required=False,
                            widget=forms.Textarea(attrs={
                                'cols': 35,
                                'rows': 4,
                                'maxlength': 150
                            }))

    field_order = [
        'start_date', 'start_time', 'end_date', 'transport_type', 'orig',
        'dest', 'notes'
    ]

    class Meta:
        model = Journey
        fields = [
            'start_date', 'start_time', 'end_date', 'orig', 'dest', 'notes',
            'transport_type'
        ]

    class Media:
        js = ('admin/js/vendor/jquery/jquery.js', 'admin/js/core.js')
        css = {'all': ('admin/css/forms.css', )}
Esempio n. 5
0
class BIForm(forms.Form):
    beginTime = forms.DateTimeField(required=True,
                                    label='beginTime',
                                    widget=widgets.AdminDateWidget())
    endTime = forms.DateTimeField(required=True,
                                  label='endTime',
                                  widget=widgets.AdminDateWidget())
Esempio n. 6
0
 class Meta:
     model = Student
     fields = '__all__'
     widgets = {
         'birthday': widgets.AdminDateWidget(),
         'start_date': widgets.AdminDateWidget(),
     }
Esempio n. 7
0
def addorder(request, client_id):
    if request.user.is_authenticated():
        cl = get_object_or_404(Client, pk=client_id)
        msg = _('New order is saved')
        title = _('Client ') + cl.client_name + _(' can add new order.')
        if request.method == 'POST':
            form = OrderForm(request.POST)
            form.fields["transp_date"].widget = widgets.AdminDateWidget()
            #show(form)
            if form.is_valid():
                order = Order(client=cl, **form.cleaned_data)
                order.save()
                return render_to_response(
                    'clients/savemsg.html', {
                        'cl': cl,
                        'msg': msg,
                    },
                    context_instance=template.RequestContext(request))
        else:
            form = OrderForm()
            form.fields["transp_date"].widget = widgets.AdminDateWidget()
        act = "/clients/" + client_id + "/addorder/"
        return render_to_response(
            'clients/addorder.html', {
                'form': form,
                'title': title,
                'cl': cl,
                'act': act,
            },
            context_instance=template.RequestContext(request))
    else:
        return HttpResponse("You must log in! Log in window under develop.")
class StatisticDownForm(ModelForm):
    start_period = forms.CharField(widget=widgets.AdminDateWidget())
    end_period = forms.CharField(widget=widgets.AdminDateWidget())

    class Meta:
        model = issues
        fields = ['workspace']
class UserExportForm(forms.Form):
    date_filter_start = forms.DateField(required=False,
                                        label="Filter activity before",
                                        widget=widgets.AdminDateWidget())
    date_filter_end = forms.DateField(required=False,
                                      label="Filter activity after",
                                      widget=widgets.AdminDateWidget())
    filter_inactive = forms.BooleanField(required=False,
                                         label="Filter users with no activity")
    include_guests = forms.BooleanField(
        required=False,
        label="Include contributors who have entered commitments")
    excel_friendly = forms.BooleanField(required=False)

    def save_to_writer(self, writer):
        date_start = self.cleaned_data[
            "date_filter_start"] if "date_filter_start" in self.cleaned_data else None
        date_end = self.cleaned_data[
            "date_filter_end"] if "date_filter_end" in self.cleaned_data else None
        queryset = Profile.objects.user_engagement(date_start=date_start,
                                                   date_end=date_end)
        if self.cleaned_data["include_guests"]:
            guest_queryset = Contributor.objects.contirbutor_engagment(
                date_start=date_start, date_end=date_end)
            queryset = queryset + guest_queryset[1:]
        for row in queryset:
            if not self.cleaned_data["filter_inactive"] or any(row[8:]):
                writer.writerow([
                    '="%s"' %
                    s if s and self.cleaned_data["excel_friendly"] else s
                    for s in row
                ])
Esempio n. 10
0
 def __init__(self, *args, **kwargs):
     super(PlanteurForm, self).__init__(*args, **kwargs)
     self.fields['dateNaissance'].widget = widgets.AdminDateWidget()
     self.fields['date_adhesion'].widget = widgets.AdminDateWidget()
     self.fields['date_fin_Diecte'].widget = widgets.AdminDateWidget()
     self.fields[
         'date_cessation_Activite'].widget = widgets.AdminDateWidget()
Esempio n. 11
0
class ReportDateSelectForm(forms.Form):
    """"""
    StartDate = forms.DateTimeField(required=True,
                                    label='起始日期',
                                    widget=widgets.AdminDateWidget())
    EndDate = forms.DateTimeField(required=True,
                                  label='终止日期',
                                  widget=widgets.AdminDateWidget())
Esempio n. 12
0
class ReportBuilderForm(forms.Form):
    custom_billing_begin = forms.DateField(
        widget=adminwidgets.AdminDateWidget(),
        required=False,
        validators=settings.DATE_VALIDATORS)
    custom_billing_end = forms.DateField(widget=adminwidgets.AdminDateWidget(),
                                         required=False,
                                         validators=settings.DATE_VALIDATORS)
Esempio n. 13
0
 class Meta:
     model = Competition
     exclude = ('administrator_code_generator', 'competitor_code_generator',
                'questionsets')
     widgets = {
         'start': widgets.AdminDateWidget(),
         'end': widgets.AdminDateWidget(),
     }
Esempio n. 14
0
class DateForm(forms.Form):
    dateDebut = forms.DateField(label='Date de début : ',
                                widget=widgets.AdminDateWidget())
    heureDebut = forms.CharField(label='Heure de début (xx:xx:xx)',
                                 max_length=8)
    dateFin = forms.DateField(label='Date de fin : ',
                              widget=widgets.AdminDateWidget())
    heureFin = forms.CharField(label='Heure de Fin (xx:xx:xx)', max_length=8)
Esempio n. 15
0
 def formfield_for_dbfield(self, db_field, **kwargs):
     """Over riding the specific form field."""
     print(db_field)
     if db_field.name == 'dob':
         kwargs['widget'] = widgets.AdminDateWidget()
     if db_field.name == 'profile_pic':
         kwargs['widget'] = widgets.AdminDateWidget()
     return super(UserAdmin, self).formfield_for_dbfield(db_field, **kwargs)
Esempio n. 16
0
    class Meta:
        model = Contract
        #fields = ['contract_num', 'contract_date', 'tourist_list']
        #fields = ('__all__')
        fields = [
            #'manager',
            #'contract_num',
            'contract_date',
            'client',
            'tour_begin_date',
            'tour_finish_date',
            'contract_sum',
            #'prepayment_sum',
            'tourist_list',
            'tour_operator',
            'resort',
            'hotel_name',
            'room_type',
            'hotel_begin_date',
            'hotel_finish_date',
            'board',
            'transfer',
            'excursion',
            'russian_guide',
            'visa_support',
            'medical_insurance',
            'non_departure_insurance',
            #'payments'
        ]

        widgets = {
            #'contract_date': forms.SelectDateWidget(years=range(timezone.now().year-3,timezone.now().year+3)),
            #'contract_num': autocomplete,
            #'contract_date': forms.SelectDateWidget(),
            #'contract_date': widgets.AdminDateWidget(format='%d/%m/%Y'),
            'contract_date': widgets.AdminDateWidget(),

            #'manager': autocomplete.ModelSelect2(),
            #'office': autocomplete.ModelSelect2(),
            'client': autocomplete.ModelSelect2(),
            'status': autocomplete.ModelSelect2(),
            'tour_begin_date': widgets.AdminDateWidget(),
            'tour_finish_date': widgets.AdminDateWidget(),

            #'signatory': autocomplete.ModelSelect2(),
            'tourist_list':
            autocomplete.ModelSelect2Multiple(url='tourist_list'),
            #'tourist_list': TouristList(url='tourist_list'),
            'tour_operator': autocomplete.ModelSelect2(),
            'resort': autocomplete.ModelSelect2(),
            'hotel_begin_date': widgets.AdminDateWidget(),
            'hotel_finish_date': widgets.AdminDateWidget(),
            'room_type': autocomplete.ModelSelect2(),
            'board': autocomplete.ModelSelect2(),

            #'doc_get_date': widgets.AdminDateWidget(),
        }
Esempio n. 17
0
 class integrationForm(forms.Form):
     _selected_action = forms.CharField(widget=forms.MultipleHiddenInput)
     fecha_asignacion = forms.DateField(widget=widgets.AdminDateWidget())
     fecha_vencimiento = forms.DateField(widget=widgets.AdminDateWidget())
     tipo_gestion = forms.ModelChoiceField(
         queryset=TipoGestion.objects.all().order_by('name'))
     eliminar = forms.BooleanField(
         required=False,
         help_text="eliminar registros despues de integrarlos")
Esempio n. 18
0
 def __init__(self, *args, **kwargs):
     super(IssuesEditForm, self).__init__(*args, **kwargs)
     self.fields['start_down_date'].widget = widgets.AdminDateWidget()
     self.fields['start_down_time'].widget = widgets.AdminTimeWidget()
     self.fields['start_issue_date'].widget = widgets.AdminDateWidget()
     self.fields['start_issue_time'].widget = widgets.AdminTimeWidget()
     self.fields['close_down_date'].widget = widgets.AdminDateWidget()
     self.fields['close_down_time'].widget = widgets.AdminTimeWidget()
     self.fields['close_issue_date'].widget = widgets.AdminDateWidget()
     self.fields['close_issue_time'].widget = widgets.AdminTimeWidget()
Esempio n. 19
0
class CalendarForm(ModelForm):
    start_date = forms.DateField(widget=widgets.AdminDateWidget(
        format='%Y%m%d'))
    end_date = forms.DateField(widget=widgets.AdminDateWidget(format='%Y%m%d'))

    class Meta:
        model = Calendar
        fields = [
            'service_id', 'monday', 'tuesday', 'wednesday', 'thursday',
            'friday', 'saturday', 'sunday', 'start_date', 'end_date'
        ]
Esempio n. 20
0
 class Meta:
     model = Penalty
     fields = [
         'date', 'car', 'driver', 'description', 'number', 'amount', 'scan',
         'obtain_date', 'payed', 'pay_date'
     ]
     widgets = {
         'date': widgets.AdminDateWidget(),
         'obtain_date': widgets.AdminDateWidget(),
         'pay_date': widgets.AdminDateWidget(),
     }
Esempio n. 21
0
class LeaveInfoForm(ModelForm):
    class Meta:
        model = LeaveInfo
        fields = [
            'isLeaving_bool', 'LeaveTime_date', 'BackTime_date',
            'Destination_text', 'StuPhone_bigint', 'Contact_text',
            'ContactPhone_bigint'
        ]

    LeaveTime_date = DateField(widget=widgets.AdminDateWidget())
    BackTime_date = DateField(widget=widgets.AdminDateWidget())
Esempio n. 22
0
File: item.py Progetto: Jokey90/aho
    class Meta:
        model = Item
        fields = [
            'type', 'car', 'number', 'start_date', 'end_date', 'company',
            'comment', 'scan'
        ]

        widgets = {
            'start_date': widgets.AdminDateWidget(),
            'end_date': widgets.AdminDateWidget(),
        }
Esempio n. 23
0
 def __init__(self, user, center, *arg, **kwargs):
     self.user = user
     self.center = center
     super(BookingForm, self).__init__(*arg, **kwargs)
     self.fields['booking_start_date'].widget = widgets.AdminDateWidget()
     self.fields['booking_end_date'].widget = widgets.AdminDateWidget()
     self.fields['phone_number'].error_messages = {
         'invalid':
         'Please make sure you use your country code (e.g. +2340000000000)',
         'required': 'Enter a valid phone number'
     }
Esempio n. 24
0
    class Meta:
        model = Tourist
        #fields = ('__all__')
        exclude = [
            'office',
        ]

        widgets = {
            'birthdate': widgets.AdminDateWidget(),
            'passport_date': widgets.AdminDateWidget(),
            'international_passport_date_of_expiry': widgets.AdminDateWidget(),
        }
Esempio n. 25
0
 def __init__(self, *args, **kwargs):
     super(IssuesForm, self).__init__(*args, **kwargs)
     self.fields['start_down_date'].widget = widgets.AdminDateWidget()
     self.fields['start_down_time'].widget = widgets.AdminTimeWidget()
     self.fields['start_issue_date'].widget = widgets.AdminDateWidget()
     self.fields['start_issue_time'].widget = widgets.AdminTimeWidget()
     self.fields[
         'group_of_reason'].initial = 'не определено'  #groups_of_reason.objects.get(pk=7)
     self.fields['solution'].initial = 'не определено'
     self.fields['current_status'].initial = status_issue.objects.get(pk=1)
     self.fields[
         'executor'].initial = 'не определено'  #User.objects.get(pk=6)
Esempio n. 26
0
class MailForm(forms.Form):
    StartDate = forms.DateTimeField(required=True,
                                    label='StartDate',
                                    widget=widgets.AdminDateWidget())
    StartTime = forms.DateTimeField(required=False,
                                    label='StartTime',
                                    widget=widgets.AdminTimeWidget())
    ExpireDate = forms.DateTimeField(required=False,
                                     label='ExpireDate',
                                     widget=widgets.AdminDateWidget())
    ExpireTime = forms.DateTimeField(required=False,
                                     label='ExpireTime',
                                     widget=widgets.AdminTimeWidget())
Esempio n. 27
0
class MeritForm(forms.Form):
    start_date = forms.DateField(initial=get_start_date_default,
                                 widget=adminwidgets.AdminDateWidget())
    end_date = forms.DateField(initial=datetime.date.today,
                               widget=adminwidgets.AdminDateWidget())
    level_one = forms.IntegerField(initial=get_default_one)
    level_two = forms.IntegerField(initial=get_default_two, required=False)
    level_three = forms.IntegerField(initial=get_default_three, required=False)
    level_four = forms.IntegerField(initial=get_default_four, required=False)
    sort_by = forms.ChoiceField(choices=(('lname', 'Student last name'),
                                         ('year', 'School year'),
                                         ('cohort', 'Primary Cohort')),
                                initial=1)
Esempio n. 28
0
 class Meta:
     model = Proxy
     fields = [
         'car',
         'driver',
         'start_date',
         'end_date',
         'type',
         'scan'
     ]
     widgets = {
         'start_date': widgets.AdminDateWidget(),
         'end_date': widgets.AdminDateWidget()
     }
Esempio n. 29
0
class TimeBasedForm(forms.Form):
    """A generic template for time and school year based forms"""
    this_year = forms.BooleanField(
        required=False,
        initial=True,
        widget=forms.CheckboxInput(
            attrs={'onclick': 'toggle("id_this_year")'}))
    all_years = forms.BooleanField(
        required=False,
        widget=forms.CheckboxInput(
            attrs={'onclick': 'toggle("id_all_years")'}))
    date_begin = forms.DateField(widget=adminwidgets.AdminDateWidget(),
                                 required=False)
    date_end = forms.DateField(widget=adminwidgets.AdminDateWidget(),
                               required=False)
    marking_period = forms.ModelMultipleChoiceField(
        required=False, queryset=MarkingPeriod.objects.all())
    include_deleted = forms.BooleanField(required=False)

    class Media:
        js = ('/static/js/time_actions.js', )

    def clean(self):
        data = self.cleaned_data
        if not data.get("this_year") and not data.get("all_years"):
            if not data.get("date_begin") or not data.get("date_end"):
                raise forms.ValidationError(
                    "You must select this year, all years, or specify a date.")
        return data

    def get_dates(self):
        """ Returns begining and start dates in a tuple
        Pass it form.cleaned_data """
        data = self.cleaned_data
        if data['this_year'] and not data['marking_period']:
            start = SchoolYear.objects.get(active_year=True).start_date
            end = SchoolYear.objects.get(active_year=True).end_date
        elif not data['this_year'] and not data['all_years']:
            start = data['date_begin']
            end = data['date_end']
        elif data['marking_period']:
            start = data['marking_period'].all().order_by(
                'start_date')[0].start_date
            end = data['marking_period'].all().order_by(
                '-end_date')[0].end_date
        else:  # all of time
            start = date(1980, 1, 1)
            end = date(2980, 1, 1)
        return (start, end)
Esempio n. 30
0
class DateForm(forms.Form):
    dateDebut = forms.DateField(label='Date de début : ',
                                widget=widgets.AdminDateWidget())
    heureDebut = forms.CharField(max_length=8,
                                 widget=forms.TextInput(attrs={
                                     'size': 10,
                                     'value': '00:00:00'
                                 }))
    dateFin = forms.DateField(label='Date de fin : ',
                              widget=widgets.AdminDateWidget())
    heureFin = forms.CharField(max_length=8,
                               widget=forms.TextInput(attrs={
                                   'size': 10,
                                   'value': '23:59:59'
                               }))