class QgisUserForm(MapModelForm): name = forms.CharField( label="User name:", required=True, widget=forms.TextInput(attrs={ 'size': 50, }), help_text="", error_messages={'required': '''Please enter the QGIS user's name'''}, ) email = forms.EmailField( label="Email:", required=True, widget=forms.TextInput(attrs={ 'size': 50, }), help_text="This will not be displayed on the map", error_messages={ 'required': '''Please enter the email address you wish to use''' }, ) home_url = forms.URLField( label="User home page:", required=False, widget=forms.TextInput(attrs={ 'size': 50, }), help_text="", ) image = forms.ImageField( label="User profile picture:", required=False, help_text="", ) geometry = forms.CharField( label="User location:", required=True, widget=EditableMap( options={ 'layers': [ 'osm.mapnik', 'osm.osmarender', 'google.streets', 'google.satellite', 'google.hybrid' ] }), help_text= "To add your location: click 'Edit' on the top-right corner of the map, and then the pencil icon", error_messages={'required': '''A location is required'''}, ) class Meta: model = QgisUser exclude = ( 'added_date', 'guid', )
class Meta: model = TaarifaConfig widgets = { 'bounds': EditableMap(options={ 'geometry': 'polygon', 'map_div_style': { 'width': '100%', } }, attrs={'id': 'bounds-edit'}) }
class QgisUserForm(MapModelForm): name = forms.CharField(label="Your name:", required=True, widget=forms.TextInput(attrs={'size': 50,}), help_text="", error_messages={'required': 'Please enter the QGIS user\'s name'}, ) email = forms.EmailField(label="Email:", required=True, widget=forms.TextInput(attrs={'size': 50,}), help_text="This will not be displayed on the map", error_messages={'required': 'Please enter the email address you wish to use'}, ) home_url = forms.URLField(label="User home page:", required=False, widget=forms.TextInput(attrs={'size': 50,}), help_text="", ) image = forms.ImageField(label="User profile picture:", required=False, help_text="", ) geometry = forms.CharField(label="User location:", required=True, widget=EditableMap( options = { 'layers': ['osm.mapnik', 'osm.osmarender'] } ), help_text="To add your location: click 'Edit' on the top-right corner of the map, and then the pencil icon", error_messages={'required': 'A location is required'}, ) def clean_geometry(self): data = self.cleaned_data['geometry'] try: utils.get_ewkt(data) except: self.cleaned_data['geometry'] = '' self.data['geometry']= '' raise forms.ValidationError("Invalid geometry") # Always return the cleaned data, whether you have changed it or # not. return data class Meta: model = QgisUser exclude = ('added_date', 'guid',)
def __init__(self, data=None, site=None, *args, **kwargs): location = kwargs['instance'] try: lon, lat = float(location.lon), float(location.lat) except TypeError: raise GeocodeError super(OrderSettingsForm, self).__init__(data, *args, **kwargs) self.fields['delivery_area'].widget = EditableMap( options={ 'geometry': 'polygon', 'isCollection': True, 'layers': ['google.streets'], 'default_lat': lat, 'default_lon': lon, 'defaultZoom': 13, 'map_options': { 'controls': ['Navigation', 'PanZoom'] } }) self.fields['order_email'].initial = location.email self.fields['order_fax'].initial = location.fax_number self.site = site
class MySingleForm(forms.Form): char = forms.CharField(max_length=10, required=False) field = forms.CharField(widget=EditableMap({"name": "Fun times"}))
class RegionSettingsForm(MediaMixin, forms.Form): full_name = forms.CharField(label=ugettext_lazy("Full name"), max_length=255, help_text=ugettext_lazy("The full name of this region, e.g. 'San Francisco'")) geom = forms.CharField(widget=EditableMap({'geometry': 'polygon'})) default_language = forms.ChoiceField(label=ugettext_lazy("Default language"), choices=LANGUAGES, required=False)
class RequestForm(ModelForm): bounds = CharField(widget=EditableMap({'geometry': 'polygon'})) class Meta: model = RequestForImagery