Skip to content

Commit

Permalink
#702: even greater accuracy for fixdictsformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Feb 26, 2017
1 parent c903797 commit beae568
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 67 deletions.
6 changes: 5 additions & 1 deletion extras/fixdictsformatting.py
Expand Up @@ -112,7 +112,11 @@ def walk_dedent_tree_node(node, children, force_split_next=False):
if node.type == token.STRING:
strings_tuple = node.parent.parent

container = strings_tuple.parent.children[0]
# compute indent
if force_split_next:
container = strings_tuple.parent.children[0]
else:
container = strings_tuple.parent.parent.children[0]
while isinstance(container, Node):
container = container.children[0]
indent = container.column + 4
Expand Down
9 changes: 4 additions & 5 deletions misago/core/migrations/0002_basic_settings.py
Expand Up @@ -34,9 +34,9 @@ def create_basic_settings_group(apps, schema_editor):
'setting': 'forum_index_title',
'name': _("Index title"),
'description': _(
"You may set custon title on "
"forum index by typing it here."
),
"You may set custon title on "
"forum index by typing it here."
),
'legend': _("Forum index"),
'field_extra': {
'max_length': 255
Expand Down Expand Up @@ -75,8 +75,7 @@ def create_basic_settings_group(apps, schema_editor):
'setting': 'email_footer',
'name': _("E-mails footer"),
'description': _(
"Optional short message included at "
"the end of e-mails sent by forum."
"Optional short message included at the end of e-mails sent by forum."
),
'legend': _("Forum e-mails"),
'field_extra': {
Expand Down
13 changes: 5 additions & 8 deletions misago/legal/migrations/0001_initial.py
Expand Up @@ -15,9 +15,8 @@ def create_legal_settings_group(apps, schema_editor):
'key': 'legal',
'name': _("Legal information"),
'description': _(
"Those settings allow you to set forum terms of "
"service and privacy policy"
),
"Those settings allow you to set forum terms of service and privacy policy."
),
'settings': [
{
'setting': 'terms_of_service_title',
Expand All @@ -35,8 +34,7 @@ def create_legal_settings_group(apps, schema_editor):
'setting': 'terms_of_service_link',
'name': _("Terms link"),
'description': _(
"If terms of service are located "
"on other page, enter there its link."
"If terms of service are located on other page, enter there its link."
),
'value': "",
'field_extra': {
Expand Down Expand Up @@ -80,9 +78,8 @@ def create_legal_settings_group(apps, schema_editor):
'setting': 'privacy_policy_link',
'name': _("Policy link"),
'description': _(
"If privacy policy is located on "
"other page, enter there its link."
),
"If privacy policy is located on other page, enter there its link."
),
'value': "",
'field_extra': {
'max_length': 255,
Expand Down
10 changes: 6 additions & 4 deletions misago/threads/api/threadendpoints/merge.py
Expand Up @@ -176,7 +176,7 @@ def merge_threads(request, validated_data, threads, poll):
new_thread = Thread(
category=validated_data['category'],
started_on=threads[0].started_on,
last_post_on=threads[0].last_post_on
last_post_on=threads[0].last_post_on,
)

new_thread.set_title(validated_data['title'])
Expand All @@ -194,7 +194,8 @@ def merge_threads(request, validated_data, threads, poll):
record_event(
request, new_thread, 'merged', {
'merged_thread': thread.title,
}, commit=False
},
commit=False,
)

new_thread.synchronize()
Expand Down Expand Up @@ -223,8 +224,9 @@ def merge_threads(request, validated_data, threads, poll):
# add top category to thread
if validated_data.get('top_category'):
categories = list(
Category.objects.all_categories()
.filter(id__in=request.user.acl_cache['visible_categories'])
Category.objects.all_categories().filter(
id__in=request.user.acl_cache['visible_categories'],
)
)
add_categories_to_items(validated_data['top_category'], categories, [new_thread])
else:
Expand Down
2 changes: 1 addition & 1 deletion misago/threads/migrations/0003_attachment_types.py
Expand Up @@ -27,7 +27,7 @@
{
'name': 'PDF',
'extensions': ('pdf', ),
'mimetypes': ('application/pdf', 'application/x-pdf', 'application/x-bzpdf', 'application/x-gzpdf'),
'mimetypes': ('application/pdf', 'application/x-pdf', 'application/x-bzpdf', 'application/x-gzpdf',),
'size_limit': 4 * 1024
},
{
Expand Down
4 changes: 2 additions & 2 deletions misago/threads/search.py
Expand Up @@ -47,8 +47,8 @@ def search(self, query, page=1):

results = {
'results': FeedSerializer(posts, many=True, context={
'user': self.request.user,
}).data
'user': self.request.user,
}).data
}
results.update(paginator)

Expand Down
5 changes: 1 addition & 4 deletions misago/users/api/userendpoints/changepassword.py
Expand Up @@ -25,10 +25,7 @@ def change_password_endpoint(request, pk=None):
)

return Response({
'detail': _(
"Password change confirmation link "
"was sent to your address."
)
'detail': _("Password change confirmation link was sent to your address.")
})
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
2 changes: 1 addition & 1 deletion misago/users/djangoadmin.py
Expand Up @@ -82,7 +82,7 @@ class UserAdmin(admin.ModelAdmin):
{
'fields': (
'username', 'email', 'rank', 'last_login', 'joined_on', 'is_staff',
'is_superuser', 'edit_from_misago_link',
'is_superuser', 'edit_from_misago_link',
)
},
],
Expand Down
13 changes: 8 additions & 5 deletions misago/users/forms/admin.py
Expand Up @@ -91,7 +91,9 @@ class EditUserForm(UserBaseForm):
)

new_password = forms.CharField(
label=_("Change password to"), widget=forms.PasswordInput, required=False
label=_("Change password to"),
widget=forms.PasswordInput,
required=False,
)

is_avatar_locked = YesNoSwitch(
Expand Down Expand Up @@ -122,7 +124,9 @@ class EditUserForm(UserBaseForm):
)

signature = forms.CharField(
label=_("Signature contents"), widget=forms.Textarea(attrs={'rows': 3}), required=False
label=_("Signature contents"),
widget=forms.Textarea(attrs={'rows': 3}),
required=False,
)
is_signature_locked = YesNoSwitch(
label=_("Lock signature"),
Expand Down Expand Up @@ -382,9 +386,8 @@ class RankForm(forms.ModelForm):
label=_("Give rank dedicated tab on users list"),
required=False,
help_text=_(
"Selecting this option will make users with this rank "
"easily discoverable by others trough dedicated page on "
"forum users list."
"Selecting this option will make users with this rank easily discoverable "
"by others through dedicated page on forum users list."
)
)

Expand Down
15 changes: 6 additions & 9 deletions misago/users/forms/auth.py
Expand Up @@ -16,13 +16,11 @@ class MisagoAuthMixin(object):
'empty_data': _("Fill out both fields."),
'invalid_login': _("Login or password is incorrect."),
'inactive_user': _(
"You have to activate your account before "
"you will be able to sign in."
),
"You have to activate your account before you will be able to sign in."
),
'inactive_admin': _(
"Your account has to be activated by "
"Administrator before you will be able "
"to sign in."
"Your account has to be activated by Administrator "
"before you will be able to sign in."
),
}

Expand Down Expand Up @@ -144,9 +142,8 @@ class ResetPasswordForm(GetUserForm):
"you will be able to request new password."
),
'inactive_admin': _(
"Administrator has to activate your account "
"before you will be able to request "
"new password."
"Administrator has to activate your account before "
"you will be able to request new password."
),
}

Expand Down
20 changes: 8 additions & 12 deletions misago/users/migrations/0002_users_settings.py
Expand Up @@ -103,9 +103,8 @@ def create_users_settings_group(apps, schema_editor):
'setting': 'default_gravatar_fallback',
'name': _("Fallback for default gravatar"),
'description': _(
"Select which avatar to use when user "
"has no gravatar associated with his "
"e-mail address."
"Select which avatar to use when user has no "
"gravatar associated with his e-mail address."
),
'value': 'dynamic',
'form_field': 'select',
Expand All @@ -120,9 +119,8 @@ def create_users_settings_group(apps, schema_editor):
'setting': 'avatar_upload_limit',
'name': _("Maximum size of uploaded avatar"),
'description': _(
"Enter maximum allowed file size "
"(in KB) for avatar uploads"
),
"Enter maximum allowed file size (in KB) for avatar uploads."
),
'python_type': 'int',
'value': 1536,
'field_extra': {
Expand Down Expand Up @@ -191,9 +189,8 @@ def create_users_settings_group(apps, schema_editor):
'key': 'captcha',
'name': _("CAPTCHA"),
'description': _(
"Those settings allow you to combat automatic "
"registrations on your forum."
),
"Those settings allow you to combat automatic registrations on your forum."
),
'settings': [
{
'setting': 'captcha_type',
Expand Down Expand Up @@ -253,9 +250,8 @@ def create_users_settings_group(apps, schema_editor):
'setting': 'qa_answers',
'name': _("Valid answers"),
'description': _(
"Enter each answer in new line. "
"Answers are case-insensitive."
),
"Enter each answer in new line. Answers are case-insensitive."
),
'value': '',
'form_field': 'textarea',
'field_extra': {
Expand Down
10 changes: 4 additions & 6 deletions misago/users/migrations/0006_update_settings.py
Expand Up @@ -89,9 +89,8 @@ def update_users_settings(apps, schema_editor):
'setting': 'default_gravatar_fallback',
'name': _("Fallback for default gravatar"),
'description': _(
"Select which avatar to use when user "
"has no gravatar associated with his "
"e-mail address."
"Select which avatar to use when user has no "
"gravatar associated with his e-mail address."
),
'value': 'dynamic',
'form_field': 'select',
Expand All @@ -106,9 +105,8 @@ def update_users_settings(apps, schema_editor):
'setting': 'avatar_upload_limit',
'name': _("Maximum size of uploaded avatar"),
'description': _(
"Enter maximum allowed file size "
"(in KB) for avatar uploads"
),
"Enter maximum allowed file size (in KB) for avatar uploads."
),
'python_type': 'int',
'default_value': 1536,
'field_extra': {
Expand Down
7 changes: 4 additions & 3 deletions misago/users/views/activation.py
Expand Up @@ -64,7 +64,8 @@ def activate_by_token(request, pk, token):
return render(
request, 'misago/activation/error.html', {
'message': e.args[0],
}, status=400
},
status=400,
)

inactive_user.requires_activation = UserModel.ACTIVATION_NONE
Expand All @@ -75,7 +76,7 @@ def activate_by_token(request, pk, token):
return render(
request, 'misago/activation/done.html', {
'message': message % {
'user': inactive_user.username,
},
'user': inactive_user.username,
},
}
)
7 changes: 3 additions & 4 deletions misago/users/views/admin/users.py
Expand Up @@ -82,9 +82,8 @@ class UsersList(UserAdmin, generic.ListView):
'name': _("Delete all"),
'icon': 'fa fa-eraser',
'confirmation': _(
"Are you sure you want to delete selected "
"users? This will also delete all content "
"associated with their accounts."
"Are you sure you want to delete selected users? "
"This will also delete all content associated with their accounts."
),
'is_atomic': False,
},
Expand Down Expand Up @@ -177,7 +176,7 @@ def action_ban(self, request, users):
if banned_value not in banned_values:
ban_kwargs.update({
'check_type': check_type,
'banned_value': banned_value
'banned_value': banned_value,
})
Ban.objects.create(**ban_kwargs)
banned_values.append(banned_value)
Expand Down
4 changes: 2 additions & 2 deletions misago/users/views/options.py
Expand Up @@ -75,7 +75,7 @@ def confirm_password_change(request, token):
return render(
request, 'misago/options/credentials_changed.html', {
'message': message % {
'user': request.user.username,
},
'user': request.user.username,
},
}
)

0 comments on commit beae568

Please sign in to comment.