From 4c5a279249a44bc921cfab5535ab69abe0311030 Mon Sep 17 00:00:00 2001 From: ashwinishinde Date: Mon, 6 Jul 2015 15:12:23 +0530 Subject: Subject: Resolve comment issue occured by Vote functionality Description: --- forums/forms.py | 24 ++++++------- forums/views.py | 4 +-- static/website/css/main.css | 4 +++ static/website/js/thread-user.js | 1 - static/website/templates/get-question.html | 19 +++++++---- static/website/templates/questions.html | 17 ++++----- website/models.py | 4 +-- website/urls.py | 2 ++ website/views.py | 55 +++++++++++++++++++++++++++--- 9 files changed, 90 insertions(+), 40 deletions(-) diff --git a/forums/forms.py b/forums/forms.py index 90a147d..05f0d56 100644 --- a/forums/forms.py +++ b/forums/forms.py @@ -15,33 +15,24 @@ from website.models import Profile class UserLoginForm(forms.Form): - username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput()) - db = forms.ChoiceField(choices=[('forum', 'forum'), ('scilab', 'scilab'), ('client2', 'client2')]) def clean(self): cleaned_data = self.cleaned_data username = cleaned_data.get('username') + print username password = cleaned_data.get('password') - db = cleaned_data.get('db') - + print password if username is None or password is None: raise forms.ValidationError("Invalid username or password") - - - if db == 'forum': - user = authenticate(username=username, password=password) - print "default" , "*******************" - else: - user = authenticate(username=username, password=password, db=db) - print db , "*******************" + user = authenticate(username=username, password=password) + if not user: raise forms.ValidationError("Invalid username or password") if not user.is_active: raise forms.ValidationError("User is blocked") cleaned_data['user'] = user - return cleaned_data class ProfileForm(forms.ModelForm): @@ -112,4 +103,9 @@ class RegisterForm(forms.Form): raise forms.ValidationError(_("This username has already existed.")) except User.DoesNotExist: pass - return username + + + + + + diff --git a/forums/views.py b/forums/views.py index 80410b4..185cc84 100644 --- a/forums/views.py +++ b/forums/views.py @@ -19,8 +19,7 @@ def account_register(request): print request.method if request.method == 'POST': form = RegisterForm(request.POST) - print form - print form.is_valid + if form.is_valid(): username = request.POST['username'] @@ -49,6 +48,7 @@ def account_register(request): } context.update(csrf(request)) return render_to_response('forums/templates/user-register.html', context) + def confirm(request, confirmation_code, username): try: user = User.objects.get(username=username) diff --git a/static/website/css/main.css b/static/website/css/main.css index 774871e..8d011fb 100644 --- a/static/website/css/main.css +++ b/static/website/css/main.css @@ -456,6 +456,10 @@ table .question a{ text-align: center; } +.ans-vote { + text-align: center; +} + .vote-up-off, .vote-up-on, .vote-down-off, .vote-down-on, .star-on, .star-off, .comment-up-off, .comment-up-on, .comment-flag, .flag-off, .vote-accepted-off, .vote-accepted-on { text-indent: -9999em; diff --git a/static/website/js/thread-user.js b/static/website/js/thread-user.js index 0dd0e89..1a089d2 100644 --- a/static/website/js/thread-user.js +++ b/static/website/js/thread-user.js @@ -270,7 +270,6 @@ $(document).ready(function() { $add_comment = $(".add-comment"); $cancel_commment = $(".cancel-comment"); $post_comment = $(".post-comment"); - $add_comment.click(function(e) { $(this).hide(); $(this).siblings(".cancel-comment").show(); diff --git a/static/website/templates/get-question.html b/static/website/templates/get-question.html index 67ac33a..ea6bfa3 100644 --- a/static/website/templates/get-question.html +++ b/static/website/templates/get-question.html @@ -109,11 +109,13 @@
+ {% for answer in answers %} +