misc: apply pre-commit-hooks (#74980)

This commit is contained in:
Valentin Deniaud 2023-03-01 15:00:56 +01:00
parent d00a36bdcf
commit eb5ea772de
15 changed files with 92 additions and 106 deletions

8
debian/control vendored
View File

@ -2,11 +2,13 @@ Source: passerelle-montpellier-sig
Maintainer: Serghei Mihai <smihai@entrouvert.com> Maintainer: Serghei Mihai <smihai@entrouvert.com>
Section: python Section: python
Priority: optional Priority: optional
Build-Depends: dh-python, debhelper-compat (= 12), python3-setuptools, python3-all Build-Depends: debhelper-compat (= 12),
dh-python,
python3-all,
python3-setuptools,
Standards-Version: 3.9.1 Standards-Version: 3.9.1
Package: python3-passerelle-montpellier-sig Package: python3-passerelle-montpellier-sig
Architecture: all Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}, python3-pyproj, python3-requests Depends: python3-pyproj, python3-requests, ${misc:Depends}, ${python3:Depends}
Description: Passerelle extension for Montpellier's GIS (Python 3) Description: Passerelle extension for Montpellier's GIS (Python 3)

View File

@ -1,5 +1,5 @@
from django.utils.text import slugify
from django import forms from django import forms
from django.utils.text import slugify
from .models import MontpellierSig from .models import MontpellierSig
@ -12,4 +12,4 @@ class MontpellierSigForm(forms.ModelForm):
def save(self, commit=True): def save(self, commit=True):
if not self.instance.slug: if not self.instance.slug:
self.instance.slug = slugify(self.instance.title) self.instance.slug = slugify(self.instance.title)
return super(MontpellierSigForm, self).save(commit=commit) return super().save(commit=commit)

View File

@ -1,7 +1,4 @@
# -*- coding: utf-8 -*- from django.db import migrations, models
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-11-19 13:51 # Generated by Django 1.11.12 on 2018-11-19 13:51
from __future__ import unicode_literals
from django.db import migrations from django.db import migrations

View File

@ -1,9 +1,8 @@
import requests
import logging import logging
import requests
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from passerelle.base.models import BaseResource from passerelle.base.models import BaseResource
from passerelle.utils.jsonresponse import APIError from passerelle.utils.jsonresponse import APIError

View File

@ -1,8 +1,8 @@
{% extends "passerelle/manage.html" %} {% extends "passerelle/manage.html" %}
{% block more-user-links %} {% block more-user-links %}
{{ block.super }} {{ block.super }}
{% if object.id %} {% if object.id %}
<a href="{% url 'montpellier-sig-view' slug=object.slug %}">{{ object.title }}</a> <a href="{% url 'montpellier-sig-view' slug=object.slug %}">{{ object.title }}</a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -2,15 +2,15 @@
{% load i18n %} {% load i18n %}
{% block appbar %} {% block appbar %}
<h2>Montpellier SIG - {{ object.title }}</h2> <h2>Montpellier SIG - {{ object.title }}</h2>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<div class="buttons"> <div class="buttons">
<button>{% trans 'Confirm Deletion' %}</button> <button>{% trans 'Confirm Deletion' %}</button>
<a class="cancel" href="{{ object.get_absolute_url }}">{% trans 'Cancel' %}</a> <a class="cancel" href="{{ object.get_absolute_url }}">{% trans 'Cancel' %}</a>
</div> </div>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -2,33 +2,33 @@
{% load i18n passerelle %} {% load i18n passerelle %}
{% block endpoints %} {% block endpoints %}
<ul> <ul>
<li>{% trans 'Listing communes:' %} <li>{% trans 'Listing communes:' %}
<a href="{% url 'montpellier-sig-communes' slug=object.slug %}">{{ site_base_uri }}{% url 'montpellier-sig-communes' slug=object.slug %}</a> <a href="{% url 'montpellier-sig-communes' slug=object.slug %}">{{ site_base_uri }}{% url 'montpellier-sig-communes' slug=object.slug %}</a>
</li> </li>
<li>{% trans 'Listing communes containing string :' %} <li>{% trans 'Listing communes containing string :' %}
<a href="{% url 'montpellier-sig-communes' slug=object.slug %}?q=montp">{{ site_base_uri }}{% url 'montpellier-sig-communes' slug=object.slug %}?q=montp</a> <a href="{% url 'montpellier-sig-communes' slug=object.slug %}?q=montp">{{ site_base_uri }}{% url 'montpellier-sig-communes' slug=object.slug %}?q=montp</a>
</li> </li>
<li>{% trans 'Listing streets:' %} <li>{% trans 'Listing streets:' %}
<a href="{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}">{{ site_base_uri }}{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}</a> <a href="{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}">{{ site_base_uri }}{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}</a>
</li> </li>
<li>{% trans 'Listing streets containing string:' %} <li>{% trans 'Listing streets containing string:' %}
<a href="{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}?q=com">{{ site_base_uri }}{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}?q=com</a> <a href="{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}?q=com">{{ site_base_uri }}{% url 'montpellier-sig-voies' slug=object.slug insee=34172 %}?q=com</a>
</li> </li>
<li>{% trans 'Listing streets numbers of a commune containing specified string in street name:' %} <li>{% trans 'Listing streets numbers of a commune containing specified string in street name:' %}
<a href="{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}">{{ site_base_uri }}{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}</a> <a href="{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}">{{ site_base_uri }}{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}</a>
</li> </li>
<li>{% trans 'Listing streets numbers of a commune containing specified string in street name:' %} <li>{% trans 'Listing streets numbers of a commune containing specified string in street name:' %}
<a href="{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}">{{ site_base_uri }}{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}?q=<i>&lt;street_number&gt;</i></a> <a href="{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}">{{ site_base_uri }}{% url 'montpellier-voies-commune' slug=object.slug insee=34172 nom_rue='lauragais' %}?q=<i>&lt;street_number&gt;</i></a>
</li> </li>
<li>{% trans 'Listing streets and communes containing specified string in their name:' %} <li>{% trans 'Listing streets and communes containing specified string in their name:' %}
<a href="{% url 'montpellier-sig-voiecommune' slug=object.slug nom_rue='montp' %}">{{ site_base_uri }}{% url 'montpellier-sig-voiecommune' slug=object.slug nom_rue='montp' %}</a> <a href="{% url 'montpellier-sig-voiecommune' slug=object.slug nom_rue='montp' %}">{{ site_base_uri }}{% url 'montpellier-sig-voiecommune' slug=object.slug nom_rue='montp' %}</a>
</li> </li>
<li>{% trans 'Get address by geographical position:' %} <li>{% trans 'Get address by geographical position:' %}
<a href="{% url 'montpellier-sig-adresse' slug=object.slug %}?lat=43.61&lon=3.87">{{ site_base_uri }}{% url 'montpellier-sig-adresse' slug=object.slug %}?lat=43.61&lon=3.87</a> <a href="{% url 'montpellier-sig-adresse' slug=object.slug %}?lat=43.61&lon=3.87">{{ site_base_uri }}{% url 'montpellier-sig-adresse' slug=object.slug %}?lat=43.61&lon=3.87</a>
</li> </li>
<li>{% trans 'Get quartier and sousquartier by street name and number:' %} <li>{% trans 'Get quartier and sousquartier by street name and number:' %}
<a href="{% url 'montpellier-sig-district' slug=object.slug insee=34172 nom_rue='ALL ALAIN CORNEAU' numero=66 %}">{{ site_base_uri }}{% url 'montpellier-sig-district' slug=object.slug insee=34172 nom_rue='ALL ALAIN CORNEAU' numero=66 %}</a> <a href="{% url 'montpellier-sig-district' slug=object.slug insee=34172 nom_rue='ALL ALAIN CORNEAU' numero=66 %}">{{ site_base_uri }}{% url 'montpellier-sig-district' slug=object.slug insee=34172 nom_rue='ALL ALAIN CORNEAU' numero=66 %}</a>
</li> </li>
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -3,33 +3,33 @@
{% load url from future %} {% load url from future %}
{% block more-user-links %} {% block more-user-links %}
{{ block.super }} {{ block.super }}
{% if not object.id %} {% if not object.id %}
<a href="{% url 'montpellier-sig-add' %}">{% trans 'Add Montpellier SIG Connector' %}</a> <a href="{% url 'montpellier-sig-add' %}">{% trans 'Add Montpellier SIG Connector' %}</a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block appbar %} {% block appbar %}
<h2>SIG - {% if object.id %}{{ object.title }}{% else %}{% trans 'New' %}{% endif %}</h2> <h2>SIG - {% if object.id %}{{ object.title }}{% else %}{% trans 'New' %}{% endif %}</h2>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<div id="form-content"> <div id="form-content">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
</div> </div>
{% block buttons %} {% block buttons %}
<div class="buttons"> <div class="buttons">
<button>{% trans "Save" %}</button> <button>{% trans "Save" %}</button>
{% if object.id %} {% if object.id %}
<a class="cancel" href="{{ object.get_absolute_url }}">{% trans 'Cancel' %}</a> <a class="cancel" href="{{ object.get_absolute_url }}">{% trans 'Cancel' %}</a>
{% else %} {% else %}
<a class="cancel" href="{% url 'add-connector' %}">{% trans 'Cancel' %}</a> <a class="cancel" href="{% url 'add-connector' %}">{% trans 'Cancel' %}</a>
{% endif %} {% endif %}
</div> </div>
{% endblock %} {% endblock %}
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,29 +1,27 @@
from django.conf.urls import include, url
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.urls import re_path
from passerelle.urls_utils import decorated_includes, required, app_enabled from passerelle.urls_utils import app_enabled, decorated_includes, required
from .views import * from .views import *
urlpatterns = [ urlpatterns = [
url(r'^(?P<slug>[\w,-]+)/communes$', CommunesView.as_view(), name='montpellier-sig-communes'), re_path(r'^(?P<slug>[\w,-]+)/communes$', CommunesView.as_view(), name='montpellier-sig-communes'),
url(r'^(?P<slug>[\w,-]+)/voies/(?P<insee>\d+)$', VoiesView.as_view(), name='montpellier-sig-voies'), re_path(r'^(?P<slug>[\w,-]+)/voies/(?P<insee>\d+)$', VoiesView.as_view(), name='montpellier-sig-voies'),
url( re_path(
r'^(?P<slug>[\w,-]+)/voies/(?P<insee>\d+)/(?P<nom_rue>[\w ]+)/numero$', r'^(?P<slug>[\w,-]+)/voies/(?P<insee>\d+)/(?P<nom_rue>[\w ]+)/numero$',
VoiesCommuneView.as_view(), VoiesCommuneView.as_view(),
name='montpellier-voies-commune', name='montpellier-voies-commune',
), ),
url( re_path(
r'^(?P<slug>[\w,-]+)/voiecommune/(?P<nom_rue>[\w ]+)$', r'^(?P<slug>[\w,-]+)/voiecommune/(?P<nom_rue>[\w ]+)$',
VoieCommuneView.as_view(), VoieCommuneView.as_view(),
name='montpellier-sig-voiecommune', name='montpellier-sig-voiecommune',
), ),
url(r'^(?P<slug>[\w,-]+)/reverse$', AdresseView.as_view(), name='montpellier-sig-adresse'), re_path(r'^(?P<slug>[\w,-]+)/reverse$', AdresseView.as_view(), name='montpellier-sig-adresse'),
url( re_path(
r'^(?P<slug>[\w,-]+)/quartier/(?P<insee>\d+)/(?P<nom_rue>[\w ]+)/(?P<numero>\d+)\w*/$', r'^(?P<slug>[\w,-]+)/quartier/(?P<insee>\d+)/(?P<nom_rue>[\w ]+)/(?P<numero>\d+)\w*/$',
DistrictView.as_view(), DistrictView.as_view(),
name='montpellier-sig-district', name='montpellier-sig-district',
), ),
url(r'^(?P<slug>[\w,-]+)/viewer/$', ViewerUrlView.as_view(), name='montpellier-sig-viewer'), re_path(r'^(?P<slug>[\w,-]+)/viewer/$', ViewerUrlView.as_view(), name='montpellier-sig-viewer'),
] ]

View File

@ -1,19 +1,17 @@
import requests
import unicodedata import unicodedata
import pyproj
from django.views.generic.detail import SingleObjectMixin, DetailView import pyproj
from django.views.generic.edit import CreateView, UpdateView, DeleteView import requests
from django.views.generic.base import View, RedirectView
from django.http import HttpResponseBadRequest from django.http import HttpResponseBadRequest
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.views.generic.base import RedirectView, View
from django.views.generic.detail import DetailView, SingleObjectMixin
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from passerelle import utils from passerelle import utils
from .models import MontpellierSig
from .forms import MontpellierSigForm from .forms import MontpellierSigForm
from .models import MontpellierSig
prefix_map = { prefix_map = {
'ALL': 'ALLEE', 'ALL': 'ALLEE',

View File

@ -3,12 +3,12 @@
import os import os
import subprocess import subprocess
import sys import sys
from distutils.cmd import Command
from distutils.command.build import build as _build
from setuptools import find_packages, setup
from setuptools.command.install_lib import install_lib as _install_lib from setuptools.command.install_lib import install_lib as _install_lib
from setuptools.command.sdist import sdist from setuptools.command.sdist import sdist
from distutils.command.build import build as _build
from distutils.cmd import Command
from setuptools import setup, find_packages
class eo_sdist(sdist): class eo_sdist(sdist):
@ -29,7 +29,7 @@ def get_version():
tag exists, take 0.0- and add the length of the commit log. tag exists, take 0.0- and add the length of the commit log.
""" """
if os.path.exists('VERSION'): if os.path.exists('VERSION'):
version_file = open('VERSION', 'r') version_file = open('VERSION')
version = version_file.read() version = version_file.read()
version_file.close() version_file.close()
return version return version

View File

@ -1,12 +1,12 @@
import json import json
import httmock
import httmock
from django.test import TestCase from django.test import TestCase
from django.test.client import Client from django.test.client import Client
from passerelle.utils.jsonresponse import APIError
from passerelle_montpellier_sig.models import MontpellierSig from passerelle_montpellier_sig.models import MontpellierSig
from passerelle_montpellier_sig.views import prefix_cleanup, split_street from passerelle_montpellier_sig.views import prefix_cleanup, split_street
from passerelle.utils.jsonresponse import APIError
class PrefixCleanupTestCase(TestCase): class PrefixCleanupTestCase(TestCase):