From 2eaf4df2c20b4fa0fed3b9e66f7d923850014103 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 16 Nov 2011 00:01:42 -0300 Subject: made a little change to experiment with the cache --- askbot/skins/default/templates/question.html | 2 ++ askbot/skins/default/templates/question/question_card.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index 7dc85d84..ee8ca6d9 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -10,7 +10,9 @@ {% endblock %} {% block content %} + {% cache 100 "booo" %} {%include "question/content.html" %} + {% endcache %} {% endblock %} {% block sidebar %} {%include "question/sidebar.html" %} diff --git a/askbot/skins/default/templates/question/question_card.html b/askbot/skins/default/templates/question/question_card.html index b1fa1743..f35e976f 100644 --- a/askbot/skins/default/templates/question/question_card.html +++ b/askbot/skins/default/templates/question/question_card.html @@ -9,7 +9,7 @@
- {% include "question/question_author_info.html" %} + {#% include "question/question_author_info.html" %#}
{{question.html}}
-- cgit v1.2.3-1-g7c22 From 9d08a3953810b02791d9da0f0dd939042b5d4b01 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 21 Nov 2011 10:36:52 -0300 Subject: Fixes incorrect question numbering reported in http://askbot.org/en/question/716/incorrect-number-of-user-questions-displayed --- .../default/templates/user_profile/user_stats.html | 2 +- askbot/views/users.py | 58 +++++++++++++++------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/askbot/skins/default/templates/user_profile/user_stats.html b/askbot/skins/default/templates/user_profile/user_stats.html index d9002d30..2551015c 100644 --- a/askbot/skins/default/templates/user_profile/user_stats.html +++ b/askbot/skins/default/templates/user_profile/user_stats.html @@ -8,7 +8,7 @@ {% include "user_profile/user_info.html" %} {% spaceless %} -

{% trans counter=questions|length %}{{counter}} Question{% pluralize %}{{counter}} Questions{% endtrans %}

+

{% trans counter=question_count %}{{counter}} Question{% pluralize %}{{counter}} Questions{% endtrans %}

{% endspaceless %} {% include "user_profile/users_questions.html" %} diff --git a/askbot/views/users.py b/askbot/views/users.py index 130f79a4..deaccb8c 100644 --- a/askbot/views/users.py +++ b/askbot/views/users.py @@ -1,7 +1,7 @@ """ :synopsis: user-centric views for askbot -This module includes all views that are specific to a given user - his or her profile, +This module includes all views that are specific to a given user - his or her profile, and other views showing profile-related information. Also this module includes the view listing all forum users. @@ -75,7 +75,7 @@ def owner_or_moderator_required(f): params = '?next=%s' % request.path return HttpResponseRedirect(reverse('user_signin') + params) return f(request, profile_owner, context) - return wrapped_func + return wrapped_func def users(request): is_paginated = True @@ -100,7 +100,7 @@ def users(request): objects_list = Paginator( models.User.objects.all().order_by( order_by_parameter - ), + ), const.USERS_PAGE_SIZE ) base_url = reverse('users') + '?sort=%s&' % sortby @@ -111,7 +111,7 @@ def users(request): username__icontains = suser ).order_by( '-reputation' - ), + ), const.USERS_PAGE_SIZE ) base_url = reverse('users') + '?name=%s&sort=%s&' % (suser, sortby) @@ -145,7 +145,7 @@ def users(request): @csrf.csrf_protect def user_moderate(request, subject, context): - """user subview for moderation + """user subview for moderation """ moderator = request.user @@ -174,7 +174,7 @@ def user_moderate(request, subject, context): if send_message_form.is_valid(): subject_line = send_message_form.cleaned_data['subject_line'] body_text = send_message_form.cleaned_data['body_text'] - + try: send_mail( subject_line = subject_line, @@ -244,7 +244,7 @@ def set_new_email(user, new_email, nomessage=False): user.email_isvalid = False user.save() #if askbot_settings.EMAIL_VALIDATION == True: - # send_new_email_key(user,nomessage=nomessage) + # send_new_email_key(user,nomessage=nomessage) @login_required @csrf.csrf_protect @@ -309,7 +309,26 @@ def user_stats(request, user, context): 'last_activity_by__silver', 'last_activity_by__bronze' )[:100] + questions = list(questions) + + #added this if to avoid another query if questions is less than 100 + if len(questions) < 100: + question_count = len(questions) + else: + question_count = models.Question.objects.filter( + **question_filter + ).order_by( + '-score', '-last_activity_at' + ).select_related( + 'last_activity_by__id', + 'last_activity_by__username', + 'last_activity_by__reputation', + 'last_activity_by__gold', + 'last_activity_by__silver', + 'last_activity_by__bronze' + ).count() + favorited_myself = models.FavoriteQuestion.objects.filter( question__in = questions, user = user @@ -384,6 +403,7 @@ def user_stats(request, user, context): 'page_title' : _('user profile overview'), 'user_status_for_display': user.get_status_display(soft = True), 'questions' : questions, + 'question_count': question_count, 'question_type' : question_type, 'answer_type' : answer_type, 'favorited_myself': favorited_myself, @@ -417,7 +437,7 @@ def user_recent(request, user, context): self.summary = summary slug_title = slugify(title) self.title_link = reverse( - 'question', + 'question', kwargs={'id':question_id} ) + u'%s' % slug_title if int(answer_id) > 0: @@ -459,11 +479,11 @@ def user_recent(request, user, context): for q in questions: q_event = Event( - q['active_at'], - q['activity_type'], - q['title'], - '', - '0', + q['active_at'], + q['activity_type'], + q['title'], + '', + '0', q['question_id'] ) activities.append(q_event) @@ -479,8 +499,8 @@ def user_recent(request, user, context): 'activity_type' : 'activity.activity_type' }, tables=['activity', 'answer', 'question'], - where=['activity.content_type_id = %s AND activity.object_id = answer.id AND ' + - 'answer.question_id=question.id AND NOT answer.deleted AND activity.user_id=%s AND '+ + where=['activity.content_type_id = %s AND activity.object_id = answer.id AND ' + + 'answer.question_id=question.id AND NOT answer.deleted AND activity.user_id=%s AND '+ 'activity.activity_type=%s AND NOT question.deleted'], params=[answer_type_id, user.id, const.TYPE_ACTIVITY_ANSWER], order_by=['-activity.active_at'] @@ -701,7 +721,7 @@ def user_recent(request, user, context): @owner_or_moderator_required def user_responses(request, user, context): """ - We list answers for question, comments, and + We list answers for question, comments, and answer accepted by others for this user. as well as mentions of the user @@ -762,7 +782,7 @@ def user_responses(request, user, context): #todo: agrupate users if response['response_id'] == last_response_id: original_response = dict.copy(filtered_response_list[len(filtered_response_list)-1]) - original_response['nested_responses'].append(response) + original_response['nested_responses'].append(response) filtered_response_list[len(filtered_response_list)-1] = original_response else: filtered_response_list.append(response) @@ -864,8 +884,8 @@ def user_reputation(request, user, context): reputes = models.Repute.objects.filter(user=user).order_by('-reputed_at') #select_related() adds stuff needed for the query reputes = reputes.select_related( - 'question__title', - 'question__id', + 'question__title', + 'question__id', 'user__username' ) #prepare data for the graph -- cgit v1.2.3-1-g7c22 From 9b8e514dd87b6ff8bf1e2fd8141b9bbbb63333fb Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 21 Nov 2011 14:58:29 -0300 Subject: Added spam filtering with recaptcha in feedback form --- askbot/forms.py | 46 +++++++++++++++++++--------- askbot/skins/default/templates/feedback.html | 13 ++++++++ askbot/views/meta.py | 18 ++++++----- 3 files changed, 55 insertions(+), 22 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index 0769f180..0479ad49 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -43,7 +43,7 @@ def clean_marked_tagnames(tagnames): wildcards.append(tagname) else: pure_tags.append(tagname) - + return pure_tags, wildcards def filter_choices(remove_choices = None, from_choices = None): @@ -75,7 +75,7 @@ COUNTRY_CHOICES = (('unknown',_('select country')),) + countries.COUNTRIES class CountryField(forms.ChoiceField): """this is better placed into the django_coutries app""" - + def __init__(self, *args, **kwargs): """sets label and the country choices """ @@ -253,7 +253,7 @@ class SummaryField(forms.CharField): class DumpUploadForm(forms.Form): """This form handles importing - data into the forum. At the moment it only + data into the forum. At the moment it only supports stackexchange import. """ dump_file = forms.FileField() @@ -397,7 +397,7 @@ class ChangeUserStatusForm(forms.Form): self.fields['user_status'].choices = user_status_choices #set prompt option as default - self.fields['user_status'].default = 'select' + self.fields['user_status'].default = 'select' self.moderator = moderator self.subject = subject @@ -542,8 +542,26 @@ class FeedbackForm(forms.Form): name = forms.CharField(label=_('Your name:'), required=False) email = forms.EmailField(label=_('Email (not shared with anyone):'), required=False) message = forms.CharField(label=_('Your message:'), max_length=800,widget=forms.Textarea(attrs={'cols':60})) + no_email = forms.BooleanField(label=_("I don't want to give my email"), required=False) next = NextUrlField() + def __init__(self, is_auth=False, *args, **kwargs): + super(FeedbackForm, self).__init__(*args, **kwargs) + if not is_auth: + if askbot_settings.USE_RECAPTCHA: + self._add_recaptcha_field() + + def _add_recaptcha_field(self): + self.fields['recaptcha'] = RecaptchaField( + private_key = askbot_settings.RECAPTCHA_SECRET, + public_key = askbot_settings.RECAPTCHA_KEY + ) + def clean(self): + super(FeedbackForm, self).clean() + if not self.cleaned_data['no_email'] and not self.cleaned_data['email']: + raise forms.ValidationError(_('Please mark "I dont want to give my mail" field.')) + return self.cleaned_data + class FormWithHideableFields(object): """allows to swap a field widget to HiddenInput() and back""" @@ -567,7 +585,7 @@ class FormWithHideableFields(object): class AskForm(forms.Form, FormWithHideableFields): """the form used to askbot questions - field ask_anonymously is shown to the user if the + field ask_anonymously is shown to the user if the if ALLOW_ASK_ANONYMOUSLY live setting is True however, for simplicity, the value will always be present in the cleaned data, and will evaluate to False if the @@ -600,7 +618,7 @@ class AskForm(forms.Form, FormWithHideableFields): """ if askbot_settings.ALLOW_ASK_ANONYMOUSLY == False: self.cleaned_data['ask_anonymously'] = False - return self.cleaned_data['ask_anonymously'] + return self.cleaned_data['ask_anonymously'] class AskByEmailForm(forms.Form): @@ -860,16 +878,16 @@ class EditUserForm(forms.Form): ) realname = forms.CharField( - label=_('Real name'), - required=False, - max_length=255, + label=_('Real name'), + required=False, + max_length=255, widget=forms.TextInput(attrs={'size' : 35}) ) website = forms.URLField( - label=_('Website'), - required=False, - max_length=255, + label=_('Website'), + required=False, + max_length=255, widget=forms.TextInput(attrs={'size' : 35}) ) @@ -957,7 +975,7 @@ class TagFilterSelectionForm(forms.ModelForm): if before != after: return True return False - + class EmailFeedSettingField(forms.ChoiceField): def __init__(self, *arg, **kwarg): @@ -1086,7 +1104,7 @@ class SimpleEmailSubscribeForm(forms.Form): ('n',_('no community email please, thanks')) ) subscribe = forms.ChoiceField( - widget=forms.widgets.RadioSelect, + widget=forms.widgets.RadioSelect, error_messages={'required':_('please choose one of the options above')}, choices=SIMPLE_SUBSCRIBE_CHOICES ) diff --git a/askbot/skins/default/templates/feedback.html b/askbot/skins/default/templates/feedback.html index 60ea2fca..ab9f2298 100644 --- a/askbot/skins/default/templates/feedback.html +++ b/askbot/skins/default/templates/feedback.html @@ -26,6 +26,14 @@ {% endif %}
{{form.email}}
+
+ +
{% endif %}
+ {% if form.recaptcha %} +
+ {{form.recaptcha}} +
+ {% endif %} {{form.next}}
  diff --git a/askbot/views/meta.py b/askbot/views/meta.py index 301a0925..493ab8ec 100644 --- a/askbot/views/meta.py +++ b/askbot/views/meta.py @@ -33,13 +33,13 @@ def config_variable(request, variable_name = None, mimetype = None): return HttpResponse(output, mimetype = mimetype) def about(request, template='about.html'): - return generic_view(request, template = template, page_class = 'meta') + return generic_view(request, template = template, page_class = 'meta') def page_not_found(request, template='404.html'): - return generic_view(request, template) + return generic_view(request, template) def server_error(request, template='500.html'): - return generic_view(request, template) + return generic_view(request, template) def faq(request): if getattr(askbot_settings, 'FORUM_FAQ',''): @@ -64,7 +64,7 @@ def faq(request): #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', - } + } return render_into_skin('faq_static.html', data, request) @csrf.csrf_protect @@ -72,9 +72,10 @@ def feedback(request): data = {'page_class': 'meta'} form = None if request.method == "POST": - form = FeedbackForm(request.POST) + form = FeedbackForm(is_auth = request.user.is_authenticated(), + data = request.POST) if form.is_valid(): - if not request.user.is_authenticated: + if not request.user.is_authenticated(): data['email'] = form.cleaned_data.get('email',None) data['message'] = form.cleaned_data['message'] data['name'] = form.cleaned_data.get('name',None) @@ -85,7 +86,8 @@ def feedback(request): request.user.message_set.create(message=msg) return HttpResponseRedirect(get_next_url(request)) else: - form = FeedbackForm(initial={'next':get_next_url(request)}) + form = FeedbackForm(is_auth = request.user.is_authenticated(), + initial={'next':get_next_url(request)}) data['form'] = form return render_into_skin('feedback.html', data, request) @@ -96,7 +98,7 @@ def privacy(request): def badges(request):#user status/reputation system #todo: supplement database data with the stuff from badges.py - known_badges = badge_data.BADGES.keys() + known_badges = badge_data.BADGES.keys() badges = BadgeData.objects.filter(slug__in = known_badges).order_by('slug') my_badges = [] if request.user.is_authenticated(): -- cgit v1.2.3-1-g7c22 From 02df54afdfa3c6cc19f66ca2ac29746d4c754aa2 Mon Sep 17 00:00:00 2001 From: Dejan Noveski Date: Thu, 24 Nov 2011 00:35:04 +0100 Subject: Test data filler management command - fill_test_content_db added. --- askbot/management/commands/fill_test_content_db.py | 223 +++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 askbot/management/commands/fill_test_content_db.py diff --git a/askbot/management/commands/fill_test_content_db.py b/askbot/management/commands/fill_test_content_db.py new file mode 100644 index 00000000..277c20e3 --- /dev/null +++ b/askbot/management/commands/fill_test_content_db.py @@ -0,0 +1,223 @@ +from django.core.management.base import NoArgsCommand +from django.contrib.auth.models import User +from askbot.models import User +from askbot.models.repute import Repute + + +NUM_USERS = 40 +# KEEP NEXT 3 SETTINGS LESS THAN OR EQUAL TO NUM_USERS! +NUM_QUESTIONS = 40 +NUM_ANSWERS = 20 +NUM_COMMENTS = 20 + +# To ensure that all the actions can be made, repute each user high positive +# karma. This can be calculated dynamically - max of MIN_REP_TO_... settings +INITIAL_REPUTATION = 500 + +# Defining template inputs. +USERNAME_TEMPLATE = "test_user_%s" +PASSWORD_TEMPLATE = "test_password_%s" +EMAIL_TEMPLATE = "test_user_%s@askbot.org" +TITLE_TEMPLATE = "Test question title No.%s" +TAGS_TEMPLATE = ["tag-%s-0", "tag-%s-1"] # len(TAGS_TEMPLATE) tags per question + +CONTENT_TEMPLATE = """Lorem lean startup ipsum product market fit customer + development acquihire technical cofounder. User engagement + **A/B** testing *shrink* a market venture capital pitch.""" + +ANSWER_TEMPLATE = """Accelerator photo sharing business school drop out ramen + hustle crush it revenue traction platforms.""" + +COMMENT_TEMPLATE = """Main differentiators business model micro economics + marketplace equity augmented reality human computer""" + + +class Command(NoArgsCommand): + + def print_if_verbose(self, text): + "Only print if user chooses verbose output" + if self.verbosity > 0: + print text + + def create_users(self): + "Create the users and return an array of created users" + users = [] + + # Keeping the created users in array - we will iterate over them + # several times, we don't want querying the model each and every time. + for i in range(NUM_USERS): + s_idx = str(i) + user = User.objects.create_user(USERNAME_TEMPLATE % s_idx, + EMAIL_TEMPLATE % s_idx) + user.set_password(PASSWORD_TEMPLATE % s_idx) + user.reputation = INITIAL_REPUTATION + user.save() + self.print_if_verbose("Created User '%s'" % user.username) + users.append(user) + return users + + + def create_questions(self, users): + "Create the questions and return the last one as active question" + + # Keeping the last active question entry for later use. Questions API + # might change, so we rely solely on User data entry API. + active_question = None + last_vote = False + # Each user posts a question + for user in users[:NUM_QUESTIONS]: + # Downvote/upvote the questions - It's reproducible, yet + # gives good randomized data + if not active_question is None: + if last_vote: + user.downvote(active_question) + self.print_if_verbose("%s downvoted a question"%( + user.username + )) + else: + user.upvote(active_question) + self.print_if_verbose("%s upvoted a question"%( + user.username + )) + last_vote = ~last_vote + + # len(TAGS_TEMPLATE) tags per question - each tag is different + tags = " ".join([t%user.id for t in TAGS_TEMPLATE]) + active_question = user.post_question( + title = TITLE_TEMPLATE % user.id, + body_text = CONTENT_TEMPLATE, + tags = tags, + ) + self.print_if_verbose("Created Question '%s' with tags: '%s'" % ( + active_question.title, tags,) + ) + return active_question + + + def create_answers(self, users, active_question): + "Create the answers for the active question, return the active answer" + active_answer = None + last_vote = False + # Now, fill the last added question with answers + for user in users[:NUM_ANSWERS]: + # We don't need to test for data validation, so ONLY users + # that aren't authors can post answer to the question + if not active_question.author is user: + # Downvote/upvote the answers - It's reproducible, yet + # gives good randomized data + if not active_answer is None: + if last_vote: + user.downvote(active_answer) + self.print_if_verbose("%s downvoted an answer"%( + user.username + )) + else: + user.upvote(active_answer) + self.print_if_verbose("%s upvoted an answer"%( + user.username + )) + last_vote = ~last_vote + + active_answer = user.post_answer( + question = active_question, + body_text = ANSWER_TEMPLATE, + follow = True + ) + self.print_if_verbose("%s posted an answer to the active question"%( + user.username + )) + # Upvote the active question + user.upvote(active_question) + # Follow the active question + user.follow_question(active_question) + self.print_if_verbose("%s followed the active question"%( + user.username) + ) + # Subscribe to the active question + user.subscribe_for_followed_question_alerts() + self.print_if_verbose("%s subscribed to followed questions"%( + user.username) + ) + return active_answer + + + def create_comments(self, users, active_question, active_answer): + """Create the comments for the active question and the active answer, + return 2 active comments - 1 question comment and 1 answer comment""" + + active_question_comment = None + active_answer_comment = None + + for user in users[:NUM_COMMENTS]: + active_question_comment = user.post_comment( + parent_post = active_question, + body_text = COMMENT_TEMPLATE + ) + self.print_if_verbose("%s posted a question comment"%user.username) + active_answer_comment = user.post_comment( + parent_post = active_answer, + body_text = COMMENT_TEMPLATE + ) + self.print_if_verbose("%s posted an answer comment"%user.username) + + # Upvote the active answer + user.upvote(active_answer) + + # Upvote active comments + if active_question_comment and active_answer_comment: + num_upvotees = NUM_COMMENTS - 1 + for user in users[:num_upvotees]: + user.upvote(active_question_comment) + user.upvote(active_answer_comment) + + return active_question_comment, active_answer_comment + + + def handle_noargs(self, **options): + + self.verbosity = int(options.get("verbosity", 1)) + + # Create Users + users = self.create_users() + + # Create Questions, vote for questions + active_question = self.create_questions(users) + + # Create Answers, vote for the answers, vote for the active question + # vote for the active answer + active_answer = self.create_answers(users, active_question) + + # Create Comments, vote for the active answer + active_question_comment, active_answer_comment = self.create_comments( + users, active_question, active_answer) + + # Edit the active question, answer and comments + active_question.author.edit_question( + question = active_question, + title = TITLE_TEMPLATE % "EDITED", + body_text = CONTENT_TEMPLATE, + revision_comment = "EDITED", + force = True + ) + self.print_if_verbose("User has edited the active question") + + active_answer.author.edit_answer( + answer = active_answer, + body_text = COMMENT_TEMPLATE, + force = True + ) + self.print_if_verbose("User has edited the active answer") + + active_answer_comment.user.edit_comment( + comment = active_answer_comment, + body_text = ANSWER_TEMPLATE + ) + self.print_if_verbose("User has edited the active answer comment") + + active_question_comment.user.edit_comment( + comment = active_question_comment, + body_text = ANSWER_TEMPLATE + ) + self.print_if_verbose("User has edited the active question comment") + + self.print_if_verbose("DONE") \ No newline at end of file -- cgit v1.2.3-1-g7c22 From 929014e8016addc3d5c9a304683888b75d20cd37 Mon Sep 17 00:00:00 2001 From: Dejan Noveski Date: Thu, 24 Nov 2011 00:37:03 +0100 Subject: Newline at EOF in fill_test_content_db.py --- askbot/management/commands/fill_test_content_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/askbot/management/commands/fill_test_content_db.py b/askbot/management/commands/fill_test_content_db.py index 277c20e3..11a838ff 100644 --- a/askbot/management/commands/fill_test_content_db.py +++ b/askbot/management/commands/fill_test_content_db.py @@ -220,4 +220,4 @@ class Command(NoArgsCommand): ) self.print_if_verbose("User has edited the active question comment") - self.print_if_verbose("DONE") \ No newline at end of file + self.print_if_verbose("DONE") -- cgit v1.2.3-1-g7c22 From 7a1a385a20f144bfa6051ceb6f4a0033f51cd13f Mon Sep 17 00:00:00 2001 From: Dejan Noveski Date: Thu, 24 Nov 2011 01:26:21 +0100 Subject: Accept a best answer at the end --- askbot/management/commands/fill_test_content_db.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/askbot/management/commands/fill_test_content_db.py b/askbot/management/commands/fill_test_content_db.py index 11a838ff..ccd37118 100644 --- a/askbot/management/commands/fill_test_content_db.py +++ b/askbot/management/commands/fill_test_content_db.py @@ -220,4 +220,11 @@ class Command(NoArgsCommand): ) self.print_if_verbose("User has edited the active question comment") + # Accept best answer + active_question.author.accept_best_answer( + answer = active_answer, + force = True, + ) + self.print_if_verbose("User has accepted a best answer") + self.print_if_verbose("DONE") -- cgit v1.2.3-1-g7c22 From 72df61547e7f48010c712a54b58981320c566be9 Mon Sep 17 00:00:00 2001 From: Dejan Noveski Date: Thu, 24 Nov 2011 01:52:31 +0100 Subject: Removed unused imports in fill_test_content_db management command --- askbot/management/commands/fill_test_content_db.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/askbot/management/commands/fill_test_content_db.py b/askbot/management/commands/fill_test_content_db.py index ccd37118..eb29d1c5 100644 --- a/askbot/management/commands/fill_test_content_db.py +++ b/askbot/management/commands/fill_test_content_db.py @@ -1,7 +1,5 @@ from django.core.management.base import NoArgsCommand -from django.contrib.auth.models import User from askbot.models import User -from askbot.models.repute import Repute NUM_USERS = 40 -- cgit v1.2.3-1-g7c22 From 35e9f039651d67635690453e59b627ececae97d8 Mon Sep 17 00:00:00 2001 From: Byron Date: Wed, 23 Nov 2011 22:11:17 -0600 Subject: Style fix in sing up with password --- .../templates/authopenid/signup_with_password.html | 2 +- askbot/skins/default/media/style/style.css | 22 ++++++++++++++++++++-- askbot/skins/default/media/style/style.less | 4 ++-- askbot/skins/default/templates/macros.html | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/askbot/skins/common/templates/authopenid/signup_with_password.html b/askbot/skins/common/templates/authopenid/signup_with_password.html index 43571c20..9911facf 100644 --- a/askbot/skins/common/templates/authopenid/signup_with_password.html +++ b/askbot/skins/common/templates/authopenid/signup_with_password.html @@ -7,7 +7,7 @@ {% endblock %} {% block content %} {% if settings.PASSWORD_REGISTER_SHOW_PROVIDER_BUTTONS == True %} -

{% trans %}Please register by clicking on any of the icons below{% endtrans %}

+

{% trans %}Please register by clicking on any of the icons below{% endtrans %}

{% csrf_token %} {# hide_local_login == True because it is password reg form #} {{ diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css index cacc8782..493acd6f 100644 --- a/askbot/skins/default/media/style/style.css +++ b/askbot/skins/default/media/style/style.css @@ -139,6 +139,10 @@ h1 { font-size: 24px; padding: 10px 0 5px 0px; } +/* ----- Extra space above for messages ----- */ +body.user-messages { + margin-top: 2.4em; +} /* ----- Custom positions ----- */ .left { float: left; @@ -449,6 +453,8 @@ h1 { width: 200px; /* widgets for question template */ + /* notify by email box */ + } .box p { margin-bottom: 4px; @@ -592,6 +598,9 @@ h1 { color: #777; text-align: center; } +.box .notify-sidebar #question-subscribe-sidebar { + margin: 7px 0 0 3px; +} .statsWidget p { color: #707070; font-size: 16px; @@ -1871,7 +1880,16 @@ span.delete-icon:hover { .users-page #id_email, .openid-signin #id_name, .meta #id_name, -.users-page #id_name { +.users-page #id_name, +.openid-signin #id_username, +.meta #id_username, +.users-page #id_username, +.openid-signin #id_password1, +.meta #id_password1, +.users-page #id_password1, +.openid-signin #id_password2, +.meta #id_password2, +.users-page #id_password2 { border: #cce6ec 3px solid; height: 25px; padding-left: 5px; @@ -1890,7 +1908,7 @@ span.delete-icon:hover { border: 0; color: #4a757f; font-weight: bold; - font-size: 12px; + font-size: 16px; height: 24px; margin-top: -2px; cursor: pointer; diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less index 3d436958..ca7a2336 100644 --- a/askbot/skins/default/media/style/style.less +++ b/askbot/skins/default/media/style/style.less @@ -2054,7 +2054,7 @@ span.delete-icon:hover { padding-left:0px; font-size:16px; } - #id_email,#id_name{ + #id_email,#id_name,#id_username,#id_password1,#id_password2{ border:#cce6ec 3px solid; height:25px; padding-left:5px; @@ -2073,7 +2073,7 @@ span.delete-icon:hover { border:0; color:@button-label; font-weight:bold; - font-size:12px; + font-size:16px; height:24px; margin-top:-2px; cursor:pointer; diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index 680b9d7b..34c7e9cc 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -221,7 +221,7 @@ poor design of the data or methods on data objects #} title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" {% endif %} rel="tag" - >{{ tag|replace('*', '✽') }} + >{{ tag|replace('*', '✽')}} {% if deletable %} Date: Wed, 23 Nov 2011 22:42:27 -0600 Subject: truncate strings lenght in widget tags list --- askbot/skins/default/templates/macros.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index 34c7e9cc..49c697a0 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -221,7 +221,7 @@ poor design of the data or methods on data objects #} title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" {% endif %} rel="tag" - >{{ tag|replace('*', '✽')}} + >{{ tag|replace('*', '✽')|truncate(24,True)}} {% if deletable %} Date: Thu, 24 Nov 2011 09:56:37 -0300 Subject: changed truncate value to 20 --- askbot/skins/default/templates/macros.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index 49c697a0..22272e9f 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -221,7 +221,7 @@ poor design of the data or methods on data objects #} title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" {% endif %} rel="tag" - >{{ tag|replace('*', '✽')|truncate(24,True)}} + >{{ tag|replace('*', '✽')|truncate(20,True)}} {% if deletable %} Date: Fri, 25 Nov 2011 16:59:58 -0300 Subject: fixed error messages display in feedback form --- askbot/forms.py | 5 +++-- askbot/skins/default/templates/feedback.html | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index 0479ad49..eb0269b1 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -539,8 +539,9 @@ class NotARobotForm(forms.Form): ) class FeedbackForm(forms.Form): - name = forms.CharField(label=_('Your name:'), required=False) - email = forms.EmailField(label=_('Email (not shared with anyone):'), required=False) + name = forms.CharField(label=_('Your name (optional):'), required=False) + email = forms.EmailField(label=_('Email (not shared with anyone):'), required=False, + help_text=_("if you don't want to give your email, check the box below, please note that we won't be able to contact you later.")) message = forms.CharField(label=_('Your message:'), max_length=800,widget=forms.Textarea(attrs={'cols':60})) no_email = forms.BooleanField(label=_("I don't want to give my email"), required=False) next = NextUrlField() diff --git a/askbot/skins/default/templates/feedback.html b/askbot/skins/default/templates/feedback.html index ab9f2298..9070d1c4 100644 --- a/askbot/skins/default/templates/feedback.html +++ b/askbot/skins/default/templates/feedback.html @@ -3,6 +3,11 @@ {% block title %}{% spaceless %}{% trans %}Feedback{% endtrans %}{% endspaceless %}{% endblock %} {% block content %}

{% trans %}Give us your feedback!{% endtrans %}

+{% if form.errors %} + + {{form.errors.__all__}} + +{%endif%} {% csrf_token %} {% if user.is_authenticated() %}

@@ -25,6 +30,7 @@ {% trans %}(please enter a valid email){% endtrans %} {% endif %}
{{form.email}} +

{{form.email.help_text}}

{% if form.recaptcha %}
+ {% if form.errors.recaptcha%} + {% trans %}(Please solve the captcha){% endtrans %} + + {% endif %} {{form.recaptcha}}
{% endif %} -- cgit v1.2.3-1-g7c22 From 010e51d10781edf796cfcdc54cd97b9fe8f1b731 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Fri, 25 Nov 2011 17:18:38 -0300 Subject: Fixed error message in feedback form --- askbot/forms.py | 13 ++++++++----- askbot/skins/default/templates/feedback.html | 3 +-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index eb0269b1..b36f0753 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -540,14 +540,14 @@ class NotARobotForm(forms.Form): class FeedbackForm(forms.Form): name = forms.CharField(label=_('Your name (optional):'), required=False) - email = forms.EmailField(label=_('Email (not shared with anyone):'), required=False, - help_text=_("if you don't want to give your email, check the box below, please note that we won't be able to contact you later.")) + email = forms.EmailField(label=_('Email:'), required=False) message = forms.CharField(label=_('Your message:'), max_length=800,widget=forms.Textarea(attrs={'cols':60})) - no_email = forms.BooleanField(label=_("I don't want to give my email"), required=False) + no_email = forms.BooleanField(label=_("I don't want to give my email:"), required=False) next = NextUrlField() def __init__(self, is_auth=False, *args, **kwargs): super(FeedbackForm, self).__init__(*args, **kwargs) + self.is_auth = is_auth if not is_auth: if askbot_settings.USE_RECAPTCHA: self._add_recaptcha_field() @@ -559,8 +559,11 @@ class FeedbackForm(forms.Form): ) def clean(self): super(FeedbackForm, self).clean() - if not self.cleaned_data['no_email'] and not self.cleaned_data['email']: - raise forms.ValidationError(_('Please mark "I dont want to give my mail" field.')) + if not self.is_auth: + if not self.cleaned_data['no_email'] and not self.cleaned_data['email']: + msg = _('Please mark "I dont want to give my mail" field.') + self._errors['email'] = self.error_class([msg]) + return self.cleaned_data class FormWithHideableFields(object): diff --git a/askbot/skins/default/templates/feedback.html b/askbot/skins/default/templates/feedback.html index 9070d1c4..85b5d00a 100644 --- a/askbot/skins/default/templates/feedback.html +++ b/askbot/skins/default/templates/feedback.html @@ -27,10 +27,9 @@

{{form.email}} -

{{form.email.help_text}}