-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains 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
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') |