moved some validation from settings page to form.

This commit is contained in:
2015-07-24 10:22:24 +01:00
parent f3d2a9e6ac
commit 744710e7d3
2 changed files with 23 additions and 15 deletions

View File

@@ -1,5 +1,8 @@
from django import forms
from django.contrib.auth.models import User
from os import path
from comic.models import Setting
@@ -174,6 +177,12 @@ class SettingsForm(forms.Form):
}
))
def clean_base_dir(self):
data = self.cleaned_data['base_dir']
if not path.isdir(data):
raise forms.ValidationError('This is not a valid Directory')
return data
@staticmethod
def get_initial_values():
base_dir, created = Setting.objects.get_or_create(name='BASE_DIR')