diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-09-22 17:50:27 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-09-22 17:50:27 -0400 |
commit | 44ca8c68afeea6848f750224d00a7d1b1bc09bcb (patch) | |
tree | b639901d9c34aaaab7b9a15840b084d4100c6a27 /askbot/utils | |
parent | 4eeda2172a28df85fa4b795f0648add1f5c27f9c (diff) | |
download | askbot-44ca8c68afeea6848f750224d00a7d1b1bc09bcb.tar.gz askbot-44ca8c68afeea6848f750224d00a7d1b1bc09bcb.tar.bz2 askbot-44ca8c68afeea6848f750224d00a7d1b1bc09bcb.zip |
improved tag validation messages and fixed bug where tags were lost in the input box on edit
Diffstat (limited to 'askbot/utils')
-rw-r--r-- | askbot/utils/decorators.py | 1 | ||||
-rw-r--r-- | askbot/utils/forms.py | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/askbot/utils/decorators.py b/askbot/utils/decorators.py index 0042df8f..da1cd7db 100644 --- a/askbot/utils/decorators.py +++ b/askbot/utils/decorators.py @@ -87,6 +87,7 @@ def ajax_only(view_func): if data is None: data = {} except Exception, e: + #todo: also check field called "message" if hasattr(e, 'messages'): if len(e.messages) > 1: message = u'<ul>' + \ diff --git a/askbot/utils/forms.py b/askbot/utils/forms.py index 6c3af066..6f57f71f 100644 --- a/askbot/utils/forms.py +++ b/askbot/utils/forms.py @@ -47,6 +47,18 @@ def get_db_object_or_404(params): #need catch-all b/c of the nature of the function raise Http404 +def format_errors(error_list): + """If there is only one error - returns a string + corresponding to that error, to remove the <ul> tag. + + If there is > 1 error - then convert the error_list into + a string. + """ + if len(error_list) == 1: + return unicode(error_list[0]) + else: + return unicode(error_list) + class StrippedNonEmptyCharField(forms.CharField): def clean(self, value): value = value.strip() |