Skip to content

Commit

Permalink
Form for a single web resource
Browse files Browse the repository at this point in the history
Adding and editing of web resource should be made in regards to Django
form management.
  • Loading branch information
Julius O committed Feb 25, 2016
1 parent 7323029 commit d2fd8de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions geokey_webresources/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""All forms for extension."""

from django.forms import ModelForm
from django.utils.html import strip_tags

from .models import WebResource


class WebResourceForm(ModelForm):
"""Form for a single web resource."""

def clean(self):
"""
Clean additional data.
Returns
-------
dict
Cleaned data.
"""
cleaned_data = super(WebResourceForm, self).clean()
cleaned_data['name'] = strip_tags(cleaned_data['name'])
cleaned_data['description'] = strip_tags(cleaned_data['description'])
return cleaned_data

class Meta:
"""Form meta."""

model = WebResource
fields = ('name', 'description', 'data_format', 'url', 'colour',
'symbol')

0 comments on commit d2fd8de

Please sign in to comment.