Created
February 21, 2013 22:34
-
-
Save hemache/5009020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
from django import forms | |
from cars import models | |
from django.contrib.humanize.templatetags.humanize import intcomma | |
# Insert an empty value which represent ANY choice | |
for attr in dir(models): | |
if attr.endswith('_CHOICES'): | |
CHOICES = list(getattr(models, attr)) | |
CHOICES.insert(0, ('', 'Any')) | |
setattr(models, attr, tuple(CHOICES)) | |
class AdvertismentSearchForm(forms.Form): | |
company = forms.ChoiceField(label='الشركة المصنعة', choices=models.COMPANY_CHOICES, required=False) | |
model = forms.ChoiceField(label='موديل', choices=(('', 'اختر الشركة اولا'),)) | |
cartype = forms.ChoiceField(label='نوع السيارة', choices=models.CARTYPE_CHOICES) | |
adv_type = forms.ChoiceField(label='المعلن', choices=models.ADVTYPE_CHOICES) | |
gear = forms.ChoiceField(label='مغير السرع', choices=models.GEAR_CHOICES) | |
bodycolor = forms.ChoiceField(label='اللون الخارجي', choices=models.COLOR_CHOICES) | |
insidecolor = forms.ChoiceField(label='اللون الداخلي', choices=models.COLOR_CHOICES) | |
seatstype = forms.ChoiceField(label='الفرش', choices=models.SEATSTYPE_CHOICES) | |
cylinders = forms.ChoiceField(label='عدد السلندرات', choices=models.CYLINDER_CHOICES) | |
price = forms.ChoiceField(label='السعر', choices=(('', 'Any'),) + tuple([(price, intcomma(price)) for price in xrange(1000000, 16000000, 1000000)]) ) | |
price_min = forms.ChoiceField(label='السعر من', choices=price.choices) | |
price_max = forms.ChoiceField(label='السعر الى', choices=price.choices) | |
made_date = forms.ChoiceField(label='السنة', choices=models.YEARS_CHOICES) | |
made_date_min = forms.ChoiceField(label='السنة من', choices=models.YEARS_CHOICES) | |
made_date_max = forms.ChoiceField(label='السنة الى', choices=models.YEARS_CHOICES) | |
mileage = forms.ChoiceField(label='المسافة', choices=models.MILEAGE_CHOICES) | |
mileage_min = forms.ChoiceField(label='المسافة من', help_text='المسافة التي سارت بها السيارة', choices=models.MILEAGE_CHOICES) | |
mileage_max = forms.ChoiceField(label='المسافة الى', choices=models.MILEAGE_CHOICES) | |
warranty = forms.BooleanField(label='التأمين') | |
tv = forms.BooleanField(label='تلفزيون') | |
dvd = forms.BooleanField(label='دي في دي') | |
cd = forms.BooleanField(label='سي دي') | |
gps = forms.BooleanField(label='نظام الخرائط') | |
slideroof = forms.BooleanField(label='فتحه سقف') | |
phone = forms.BooleanField(label='تليفون') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment