Skip to content

Commit

Permalink
Run code_checks
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Aug 18, 2023
1 parent 3da5292 commit d5c3bb1
Show file tree
Hide file tree
Showing 39 changed files with 106 additions and 112 deletions.
2 changes: 1 addition & 1 deletion code_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_current_msgids():
saved_msgids = get_current_msgids()

# re-extract locale files from source code
ignore_paths = ("env/*", "src/*", "fabric/*", "media/*", "sitestatic/*", "static/*", "node_modules/*")
ignore_paths = (".venv/*", "env/*", "src/*", "fabric/*", "media/*", "sitestatic/*", "static/*", "node_modules/*")
ignore_args = " ".join([f'--ignore="{p}"' for p in ignore_paths])

cmd(f"python manage.py makemessages -a -e html,txt,py --no-location --no-wrap --symlinks {ignore_args}")
Expand Down
7 changes: 3 additions & 4 deletions ureport/admins/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.orgs.models import Org
from dash.orgs.views import OrgPermsMixin
from smartmin.views import SmartCRUDL, SmartUpdateView

from django import forms
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org
from dash.orgs.views import OrgPermsMixin
from smartmin.views import SmartCRUDL, SmartUpdateView
from ureport.admins import OrgCache, refresh_caches


Expand Down
8 changes: 4 additions & 4 deletions ureport/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import json

import six
from dash.categories.models import Category
from dash.dashblocks.models import DashBlock
from dash.orgs.models import Org
from dash.stories.models import Story
from rest_framework import serializers
from rest_framework.fields import SerializerMethodField
from sorl.thumbnail import get_thumbnail

from dash.categories.models import Category
from dash.dashblocks.models import DashBlock
from dash.orgs.models import Org
from dash.stories.models import Story
from ureport.assets.models import Image
from ureport.news.models import NewsItem, Video
from ureport.polls.models import Poll
Expand Down
8 changes: 4 additions & 4 deletions ureport/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from random import randint

import six
from dash.categories.models import Category
from dash.dashblocks.models import DashBlock, DashBlockType
from dash.orgs.models import Org
from dash.stories.models import Story
from mock import patch
from rest_framework import status
from rest_framework.test import APITestCase

from django.contrib.auth.models import User
from django.utils import timezone

from dash.categories.models import Category
from dash.dashblocks.models import DashBlock, DashBlockType
from dash.orgs.models import Org
from dash.stories.models import Story
from ureport.api.serializers import CategoryReadSerializer, StoryReadSerializer, generate_absolute_url_from_file
from ureport.contacts.models import ReportersCounter
from ureport.flows.models import FlowResult
Expand Down
6 changes: 3 additions & 3 deletions ureport/api/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.dashblocks.models import DashBlock
from dash.orgs.models import Org
from dash.stories.models import Story
from rest_framework.generics import ListAPIView, RetrieveAPIView

from django.db.models import Q

from dash.dashblocks.models import DashBlock
from dash.orgs.models import Org
from dash.stories.models import Story
from ureport.api.serializers import (
DashblockReadSerializer,
ImageReadSerializer,
Expand Down
6 changes: 3 additions & 3 deletions ureport/assets/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.orgs.models import Org
from smartmin.models import SmartModel

from django.db import models
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org
from smartmin.models import SmartModel

BANNER = "B"
PATTERN = "P"
FLAG = "F"
Expand Down
5 changes: 2 additions & 3 deletions ureport/assets/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView

from django.db.models.functions import Lower

from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView
from ureport.assets.models import Image


Expand Down
2 changes: 1 addition & 1 deletion ureport/backend/floip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from collections import defaultdict

import requests
from dash.utils.sync import BaseSyncer, SyncOutcome, sync_local_to_changes
from django_redis import get_redis_connection
from temba_client.v2 import TembaClient

from django.conf import settings
from django.core.cache import cache
from django.utils import timezone

from dash.utils.sync import BaseSyncer, SyncOutcome, sync_local_to_changes
from ureport.contacts.models import Contact
from ureport.locations.models import Boundary
from ureport.polls.models import Poll, PollQuestion, PollResponseCategory, PollResult
Expand Down
4 changes: 2 additions & 2 deletions ureport/backend/rapidpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
from datetime import timedelta

import requests
from dash.utils import is_dict_equal
from dash.utils.sync import BaseSyncer, sync_local_to_changes, sync_local_to_set
from django_redis import get_redis_connection
from temba_client.exceptions import TembaRateExceededError
from temba_client.v2.types import Run

from django.core.cache import cache
from django.utils import timezone

from dash.utils import is_dict_equal
from dash.utils.sync import BaseSyncer, sync_local_to_changes, sync_local_to_set
from ureport.contacts.models import Contact, ContactField
from ureport.flows.models import FlowResultCategory
from ureport.locations.models import Boundary
Expand Down
6 changes: 3 additions & 3 deletions ureport/backend/tests/test_floip.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.categories.models import Category
from dash.test import MockClientQuery
from dash.utils.sync import SyncOutcome
from mock import patch
from temba_client.v2.types import Contact as TembaContact, ObjectRef

from dash.categories.models import Category
from dash.test import MockClientQuery
from dash.utils.sync import SyncOutcome
from ureport.backend.floip import ContactSyncer, FLOIPBackend
from ureport.contacts.models import Contact
from ureport.flows.models import FlowResult, FlowResultCategory
Expand Down
6 changes: 3 additions & 3 deletions ureport/backend/tests/test_rapidpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import logging
from datetime import timedelta

from dash.categories.models import Category
from dash.test import MockClientQuery
from dash.utils.sync import SyncOutcome
from mock import PropertyMock, patch
from temba_client.exceptions import TembaRateExceededError
from temba_client.v2.types import (
Expand All @@ -25,6 +22,9 @@
from django.test import override_settings
from django.utils import timezone

from dash.categories.models import Category
from dash.test import MockClientQuery
from dash.utils.sync import SyncOutcome
from ureport.backend.rapidpro import BoundarySyncer, ContactSyncer, FieldSyncer, RapidProBackend
from ureport.contacts.models import Contact, ContactField
from ureport.flows.models import FlowResult, FlowResultCategory
Expand Down
6 changes: 3 additions & 3 deletions ureport/bots/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dash.orgs.models import Org
from smartmin.models import SmartModel

from django.db import models
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org
from smartmin.models import SmartModel


class Bot(SmartModel):
org = models.ForeignKey(
Expand Down
5 changes: 2 additions & 3 deletions ureport/bots/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView

from django import forms
from django.db.models.functions import Lower
from django.utils.translation import gettext_lazy as _

from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView
from ureport.bots.models import Bot


Expand Down
2 changes: 1 addition & 1 deletion ureport/contacts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import time
from collections import defaultdict

from dash.orgs.models import Org, OrgBackend
from django_redis import get_redis_connection

from django.db import connection, models
from django.db.models import Count, Sum
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org, OrgBackend
from ureport.utils import chunk_list

CONTACT_LOCK_KEY = "lock:contact:%d:%s"
Expand Down
6 changes: 3 additions & 3 deletions ureport/contacts/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import time

from celery.utils.log import get_task_logger
from dash.orgs.models import Org, TaskState
from dash.orgs.tasks import org_task
from dash.utils.sync import SyncOutcome
from django_redis import get_redis_connection

from django.core.cache import cache
from django.utils import timezone

from dash.orgs.models import Org, TaskState
from dash.orgs.tasks import org_task
from dash.utils.sync import SyncOutcome
from ureport.celery import app
from ureport.contacts.models import Contact, ReportersCounter
from ureport.stats.models import ContactActivity
Expand Down
4 changes: 2 additions & 2 deletions ureport/contacts/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.orgs.models import TaskState
from dash.utils.sync import SyncOutcome
from mock import patch

from dash.orgs.models import TaskState
from dash.utils.sync import SyncOutcome
from ureport.contacts.models import Contact, ContactField, ReportersCounter
from ureport.contacts.tasks import check_contacts_count_mismatch, pull_contacts, update_org_contact_count
from ureport.locations.models import Boundary
Expand Down
3 changes: 2 additions & 1 deletion ureport/countries/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import regex
import six
from django_countries.fields import CountryField
from smartmin.models import SmartModel

from django.db import models
from django.utils.translation import gettext_lazy as _

from smartmin.models import SmartModel


class CountryAlias(SmartModel):
country = CountryField()
Expand Down
4 changes: 2 additions & 2 deletions ureport/countries/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView

from django import forms

from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView

from .models import CountryAlias


Expand Down
4 changes: 2 additions & 2 deletions ureport/flows/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dash.orgs.models import Org

from django.db import models

from dash.orgs.models import Org

# Create your models here.


Expand Down
5 changes: 3 additions & 2 deletions ureport/jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

import feedparser
import six
from dash.orgs.models import Org
from smartmin.models import SmartModel

from django.conf import settings
from django.core.cache import cache
from django.db import models
from django.utils.html import strip_tags
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org
from smartmin.models import SmartModel

RSS_JOBS_FEED_CACHE_TIME = getattr(settings, "RSS_JOBS_FEED_CACHE_TIME", 60 * 60 * 6)
RSS_JOBS_KEY = "jobsource:%d:%d"

Expand Down
5 changes: 2 additions & 3 deletions ureport/jobs/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView

from django.utils.translation import gettext_lazy as _

from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView
from ureport.jobs.models import JobSource


Expand Down
4 changes: 2 additions & 2 deletions ureport/landingpages/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import functools

import dash.utils

import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models

import dash.utils


class Migration(migrations.Migration):
initial = True
Expand Down
7 changes: 3 additions & 4 deletions ureport/landingpages/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from functools import partial

from dash.orgs.models import Org
from dash.utils import generate_file_path
from smartmin.models import SmartModel

from django.db import models
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org
from dash.utils import generate_file_path
from smartmin.models import SmartModel
from ureport.bots.models import Bot


Expand Down
5 changes: 2 additions & 3 deletions ureport/landingpages/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView

from django import forms
from django.db.models.functions import Lower
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _

from dash.orgs.views import OrgObjPermsMixin, OrgPermsMixin
from smartmin.views import SmartCreateView, SmartCRUDL, SmartListView, SmartUpdateView
from ureport.bots.models import Bot
from ureport.landingpages.models import LandingPage

Expand Down
3 changes: 2 additions & 1 deletion ureport/locations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

import json

from dash.orgs.models import Org, OrgBackend
from django_redis import get_redis_connection

from django.db import models
from django.utils.translation import gettext_lazy as _

from dash.orgs.models import Org, OrgBackend

BOUNDARY_LOCK_KEY = "lock:boundary:%d:%s"


Expand Down
Loading

0 comments on commit d5c3bb1

Please sign in to comment.