[damned-lies] chore: flake8 fixes on vertimus
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] chore: flake8 fixes on vertimus
- Date: Fri, 7 May 2021 12:21:44 +0000 (UTC)
commit 0073e77aadbe9715c0b737036f1796d36b7ece8d
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date: Fri Apr 30 11:28:33 2021 +0200
chore: flake8 fixes on vertimus
vertimus/feeds.py | 3 ++-
vertimus/migrations/0006_pofile_path_relative.py | 8 ++++----
vertimus/models.py | 26 +++++++++++++-----------
vertimus/tests/tests.py | 4 ++--
vertimus/views.py | 12 +++++------
5 files changed, 28 insertions(+), 25 deletions(-)
---
diff --git a/vertimus/feeds.py b/vertimus/feeds.py
index 910574ac..d1a5587b 100644
--- a/vertimus/feeds.py
+++ b/vertimus/feeds.py
@@ -61,7 +61,8 @@ class LatestActionsByTeam(Feed):
def title(self, obj):
return _("%(site)s — Workflow actions of the %(lang)s team") % {
- 'site': settings.SITE_DOMAIN, 'lang': obj}
+ 'site': settings.SITE_DOMAIN, 'lang': obj
+ }
def link(self, obj):
if not obj:
diff --git a/vertimus/migrations/0006_pofile_path_relative.py
b/vertimus/migrations/0006_pofile_path_relative.py
index bbf8ab51..0818cb8c 100644
--- a/vertimus/migrations/0006_pofile_path_relative.py
+++ b/vertimus/migrations/0006_pofile_path_relative.py
@@ -4,8 +4,8 @@ from django.db import migrations
def strip_path_prefix(apps, schema_editor):
- Action = apps.get_model("vertimus", "Action")
- ActionArchived = apps.get_model("vertimus", "Action")
+ action = apps.get_model("vertimus", "Action")
+ action_archived = apps.get_model("vertimus", "Action")
media_dir = os.path.basename(settings.MEDIA_ROOT)
def strip_path(action):
@@ -13,9 +13,9 @@ def strip_path_prefix(apps, schema_editor):
action.merged_file.path = old_path.split('/' + media_dir + '/')[1]
action.merged_file.save()
- for act in Action.objects.filter(merged_file__isnull=False):
+ for act in action.objects.filter(merged_file__isnull=False):
strip_path(act)
- for act in ActionArchived.objects.filter(merged_file__isnull=False):
+ for act in action_archived.objects.filter(merged_file__isnull=False):
strip_path(act)
diff --git a/vertimus/models.py b/vertimus/models.py
index 23fcca09..5472a6a6 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -1,6 +1,6 @@
import os
-import sys
import shutil
+import sys
from datetime import datetime, timedelta
from django.conf import settings
@@ -14,12 +14,11 @@ from django.utils.translation import (
)
from common.utils import run_shell_command, send_mail
+from languages.models import Language
+from people.models import Person
from stats.models import Branch, Domain, Statistics, PoFile, UnableToCommit
from stats.signals import pot_has_changed
from stats.utils import is_po_reduced, po_grep
-from languages.models import Language
-from people.models import Person
-
from teams.models import Role
@@ -111,8 +110,9 @@ class State(models.Model):
The first level is 1."""
assert level > 0, "Level must be greater than 0"
- query = ActionArchived.objects.filter(state_db=self).values('sequence').distinct(
- ).order_by('-sequence')[level-1:level]
+ query = ActionArchived.objects.filter(
+ state_db=self
+ ).values('sequence').distinct().order_by('-sequence')[level - 1:level]
sequence = None
if len(query) > 0:
sequence = query[0]['sequence']
@@ -143,8 +143,10 @@ class StateNone(State):
def get_available_actions(self, person):
action_names = []
- if ((self.language.team and person.is_translator(self.language.team))
- or person.is_maintainer_of(self.branch.module)):
+ if (
+ (self.language.team and person.is_translator(self.language.team))
+ or person.is_maintainer_of(self.branch.module)
+ ):
action_names = ['RT']
return self._get_available_actions(person, action_names)
@@ -388,8 +390,8 @@ class ActionAbstract(models.Model):
@property
def can_build(self):
return (
- not isinstance(self, ActionArchived) and
- self.state_db.domain.can_build_docs(self.state_db.branch)
+ not isinstance(self, ActionArchived)
+ and self.state_db.domain.can_build_docs(self.state_db.branch)
)
@property
@@ -429,7 +431,7 @@ class ActionAbstract(models.Model):
'title': gettext("Uploaded file by %(name)s on %(date)s") % {
'name': action.person.name if action.person else gettext('deleted account'),
'date': action.created},
- })
+ })
return history
@@ -598,7 +600,7 @@ class ActionArchived(ActionAbstract):
).annotate(
max_created=Max('created')
).filter(
- max_created__lt=datetime.now()-timedelta(days=days)
+ max_created__lt=datetime.now() - timedelta(days=days)
):
# Call each action delete() so as file is also deleted
for act in ActionArchived.objects.filter(sequence=action['sequence']):
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 01822729..82bc7cd9 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -278,10 +278,10 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
def test_send_mail_translated(self):
team = Team.objects.create(name='zh', description='Chinese', mailing_list='zh example org')
- zh_CN = Language.objects.create(name='Chinese', locale='zh_CN', team=team)
+ zh_cn = Language.objects.create(name='Chinese', locale='zh_CN', team=team)
call_command('compile-trans', locale='zh_CN')
- state = StateNone(branch=self.b, domain=self.d, language=zh_CN)
+ state = StateNone(branch=self.b, domain=self.d, language=zh_cn)
action = Action.new_by_name('WC', person=self.pn)
action.apply_on(state, {'send_to_ml': True, 'comment': "Comment"})
self.assertEqual(len(mail.outbox), 1)
diff --git a/vertimus/views.py b/vertimus/views.py
index d0d40a78..0c6a1d00 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -170,10 +170,10 @@ def get_vertimus_state(branch, domain, language, stats=None):
def vertimus_diff(request, action_id_1, action_id_2, level):
"""Show a diff between current action po file and previous file"""
if int(level) != 0:
- ActionReal = ActionArchived
+ action_real = ActionArchived
else:
- ActionReal = Action
- action_1 = get_object_or_404(ActionReal, pk=action_id_1)
+ action_real = Action
+ action_1 = get_object_or_404(action_real, pk=action_id_1)
state = action_1.state_db
file_path_1 = action_1.most_uptodate_filepath
@@ -189,7 +189,7 @@ def vertimus_diff(request, action_id_1, action_id_2, level):
if action_id_2 not in (None, 0):
# 1) id_2 specified in URL
- action_2 = get_object_or_404(ActionReal, pk=action_id_2)
+ action_2 = get_object_or_404(action_real, pk=action_id_2)
file_path_2 = action_2.most_uptodate_filepath
descr_2 = _('<a href="%(url)s">Uploaded file</a> by %(name)s on %(date)s') % {
'url': action_2.most_uptodate_file.url,
@@ -261,8 +261,8 @@ def activity_by_language(request, locale):
states = State.objects.filter(language=language).exclude(name='None')
context = {
'pageSection': "languages",
- 'language': language,
- 'activities': states,
+ 'language': language,
+ 'activities': states,
}
return render(request, 'vertimus/activity_summary.html', context)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]