Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Jan 17, 2024
1 parent 59279db commit 1147f16
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 25 deletions.
1 change: 0 additions & 1 deletion wagtail_localize_git/importer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.core.exceptions import ValidationError
from django.db import transaction

from wagtail_localize.models import (
MissingRelatedObjectError,
StringNotUsedInContext,
Expand Down
3 changes: 2 additions & 1 deletion wagtail_localize_git/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 3.0.8 on 2020-07-28 09:54

from django.db import migrations, models
import django.db.models.deletion

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True
Expand Down
16 changes: 12 additions & 4 deletions wagtail_localize_git/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from wagtail.images.models import AbstractImage
from wagtail.models import Locale, Page
from wagtail.snippets.models import get_snippet_models

from wagtail_localize.models import TranslatableObject


Expand All @@ -23,6 +22,9 @@ class Resource(models.Model):
class Meta:
ordering = ["path"]

def __str__(self):
return f"Resource ({self.pk}: {str(self.object)})"

@classmethod
def get_for_object(cls, object):
try:
Expand Down Expand Up @@ -81,6 +83,12 @@ class SyncLog(models.Model):
time = models.DateTimeField(auto_now_add=True)
commit_id = models.CharField(max_length=40, blank=True)

class Meta:
ordering = ["time"]

def __str__(self):
return f"SyncLog ({self.pk}: {self.action} - {self.time} - {self.commit_id})"

def add_translation(self, translation):
SyncLogResource.objects.create(
log=self,
Expand All @@ -89,9 +97,6 @@ def add_translation(self, translation):
source_id=translation.source_id,
)

class Meta:
ordering = ["time"]


class SyncLogResourceQuerySet(models.QuerySet):
def unique_resources(self):
Expand Down Expand Up @@ -133,3 +138,6 @@ class SyncLogResource(models.Model):

class Meta:
ordering = ["log__time", "resource__path"]

def __str__(self):
return f"SyncLogResource ({self.pk}: {self.log_id}, {self.resource_id}, {self.locale_id})"
1 change: 0 additions & 1 deletion wagtail_localize_git/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.db import transaction
from django.utils.module_loading import import_string
from wagtail.models import Locale

from wagtail_localize.models import Translation

from .git import Repository
Expand Down
7 changes: 4 additions & 3 deletions wagtail_localize_git/test/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Generated by Django 4.1.1 on 2022-09-19 19:41

from django.db import migrations, models
import django.db.models.deletion
import uuid

import django.db.models.deletion
import wagtail.fields as wagtail_fields

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True
Expand Down Expand Up @@ -34,7 +36,6 @@ class Migration(migrations.Migration):
blank=True,
default="",
max_length=255,
null=True,
verbose_name="char field",
),
),
Expand Down
3 changes: 1 addition & 2 deletions wagtail_localize_git/test/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
from wagtail.fields import RichTextField
from wagtail.models import Page, TranslatableMixin
from wagtail.snippets.models import register_snippet

from wagtail_localize.fields import SynchronizedField, TranslatableField


class TestPage(Page):
test_charfield = models.CharField(
gettext_lazy("char field"), max_length=255, blank=True, null=True, default=""
gettext_lazy("char field"), max_length=255, blank=True, default=""
)
test_textfield = models.TextField(blank=True)
test_richtextfield = RichTextField(blank=True)
Expand Down
2 changes: 1 addition & 1 deletion wagtail_localize_git/test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "c6u0-9c!7nilj_ysatsda0(f@e_2mws2f!6m0n^o*4#*q#kzp)"
SECRET_KEY = "not-a-secret" # noqa: S105

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down
2 changes: 1 addition & 1 deletion wagtail_localize_git/tests/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from django.test import TestCase
from django.utils import timezone
from wagtail.models import Locale, Page

from wagtail_localize.models import (
MissingRelatedObjectError,
Translation,
TranslationSource,
)

from wagtail_localize_git.importer import Importer
from wagtail_localize_git.models import Resource, SyncLog
from wagtail_localize_git.test.models import TestPage
Expand Down
2 changes: 1 addition & 1 deletion wagtail_localize_git/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from wagtail.images.models import Image
from wagtail.images.tests.utils import get_test_image_file
from wagtail.models import Page, Site

from wagtail_localize.models import TranslationSource

from wagtail_localize_git.models import Resource
from wagtail_localize_git.test.models import TestPage, TestSnippet

Expand Down
14 changes: 6 additions & 8 deletions wagtail_localize_git/tests/test_sync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import unittest

from pathlib import PurePosixPath
Expand All @@ -8,8 +7,8 @@

from django.test import TestCase, override_settings
from wagtail.models import Locale, Page

from wagtail_localize.models import StringTranslation, Translation, TranslationSource

from wagtail_localize_git.models import Resource, SyncLog
from wagtail_localize_git.sync import SyncPushError, _pull, _push, get_sync_manager
from wagtail_localize_git.test.models import TestPage
Expand Down Expand Up @@ -276,13 +275,12 @@ def test_push_something(self):
# Check that the source and translation files were written
# Build a dictionary of calls to RepositoryWriter.write_file(). Keyed by first argument (filename)
# Note, this check only works on Python 3.8+
if sys.version_info >= (3, 8):
mock_calls = {
call.args[0]: call for call in repo.writer().write_file.mock_calls
}
mock_calls = {
call.args[0]: call for call in repo.writer().write_file.mock_calls
}

self.assertIn("templates/pages/test-page.pot", mock_calls.keys())
self.assertIn("locales/fr/pages/test-page.po", mock_calls.keys())
self.assertIn("templates/pages/test-page.pot", mock_calls.keys())
self.assertIn("locales/fr/pages/test-page.po", mock_calls.keys())

# Check that the repo was pushed
repo.push.assert_called_once()
Expand Down
2 changes: 1 addition & 1 deletion wagtail_localize_git/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from django.urls import reverse
from wagtail.models import Locale, Page
from wagtail.test.utils import WagtailTestUtils

from wagtail_localize.models import Translation, TranslationSource

from wagtail_localize_git.models import Resource, SyncLog, SyncLogResource
from wagtail_localize_git.test.models import TestPage

Expand Down
1 change: 0 additions & 1 deletion wagtail_localize_git/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import redirect, render

from wagtail_localize.models import Translation

from .models import Resource, SyncLog, SyncLogResource
Expand Down

0 comments on commit 1147f16

Please sign in to comment.