ci: disable pylint's bad-continuation to please black
This commit is contained in:
parent
4ebbc6f065
commit
74b2b26a20
|
@ -1,6 +1,6 @@
|
||||||
[MASTER]
|
[MASTER]
|
||||||
|
|
||||||
disable=redefined-outer-name,arguments-differ,no-self-use,cyclic-import,fixme,locally-disabled,unpacking-non-sequence,too-many-ancestors,too-many-branches,too-few-public-methods,import-outside-toplevel
|
disable=redefined-outer-name,arguments-differ,no-self-use,cyclic-import,fixme,locally-disabled,unpacking-non-sequence,too-many-ancestors,too-many-branches,too-few-public-methods,import-outside-toplevel,bad-continuation
|
||||||
load-plugins=pylint_django,pylint.extensions.bad_builtin
|
load-plugins=pylint_django,pylint.extensions.bad_builtin
|
||||||
extension-pkg-whitelist=lxml
|
extension-pkg-whitelist=lxml
|
||||||
const-rgx=[a-zA-Z0-9_]{1,40}$
|
const-rgx=[a-zA-Z0-9_]{1,40}$
|
||||||
|
|
|
@ -13,8 +13,8 @@ class TagModelForm(forms.ModelForm):
|
||||||
tags = instance.tags if instance else {}
|
tags = instance.tags if instance else {}
|
||||||
# Make sure all predefined tags exist in tags, and set default if they don't
|
# Make sure all predefined tags exist in tags, and set default if they don't
|
||||||
predefined_tags = (
|
predefined_tags = (
|
||||||
self._meta.model().get_predefined_tags()
|
self._meta.model().get_predefined_tags() # pylint: disable=no-member
|
||||||
) # pylint: disable=no-member
|
)
|
||||||
for key, value in predefined_tags.items():
|
for key, value in predefined_tags.items():
|
||||||
if key not in tags:
|
if key not in tags:
|
||||||
tags[key] = value
|
tags[key] = value
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
"""passbook decorators"""
|
|
||||||
from time import time as timestamp
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.shortcuts import redirect
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.functional import wraps
|
|
||||||
from django.utils.http import urlencode
|
|
||||||
|
|
||||||
RE_AUTH_KEY = getattr(settings, "RE_AUTH_KEY", "passbook_require_re_auth_done")
|
|
||||||
RE_AUTH_MARGAIN = getattr(settings, "RE_AUTH_MARGAIN", 300)
|
|
||||||
|
|
||||||
|
|
||||||
def reauth_required(view_function):
|
|
||||||
"""Decorator to force a re-authentication before continuing"""
|
|
||||||
|
|
||||||
@wraps(view_function)
|
|
||||||
def wrap(*args, **kwargs):
|
|
||||||
"""check if user just authenticated or not"""
|
|
||||||
|
|
||||||
request = args[0] if args else None
|
|
||||||
# Check if user is authenticated at all
|
|
||||||
if not request or not request.user or not request.user.is_authenticated:
|
|
||||||
return redirect(reverse("account-login"))
|
|
||||||
|
|
||||||
now = timestamp()
|
|
||||||
|
|
||||||
if RE_AUTH_KEY in request.session and request.session[RE_AUTH_KEY] < (
|
|
||||||
now - RE_AUTH_MARGAIN
|
|
||||||
):
|
|
||||||
# Timestamp in session but expired
|
|
||||||
del request.session[RE_AUTH_KEY]
|
|
||||||
|
|
||||||
if RE_AUTH_KEY not in request.session:
|
|
||||||
# Timestamp not in session, force user to reauth
|
|
||||||
return redirect(
|
|
||||||
reverse("account-reauth") + "?" + urlencode({"next": request.path})
|
|
||||||
)
|
|
||||||
|
|
||||||
if (
|
|
||||||
RE_AUTH_KEY in request.session
|
|
||||||
and request.session[RE_AUTH_KEY] >= (now - RE_AUTH_MARGAIN)
|
|
||||||
and request.session[RE_AUTH_KEY] <= now
|
|
||||||
):
|
|
||||||
# Timestamp in session and valid
|
|
||||||
return view_function(*args, **kwargs)
|
|
||||||
|
|
||||||
# This should never be reached, just return False
|
|
||||||
return False # pragma: no cover
|
|
||||||
|
|
||||||
return wrap
|
|
|
@ -3,6 +3,7 @@ from hashlib import md5
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
|
from django.template import Context
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
|
@ -15,9 +16,10 @@ register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def back(context):
|
def back(context: Context) -> str:
|
||||||
"""Return a link back (either from GET paramter or referer."""
|
"""Return a link back (either from GET paramter or referer."""
|
||||||
|
if "request" not in context:
|
||||||
|
return ""
|
||||||
request = context.get("request")
|
request = context.get("request")
|
||||||
url = ""
|
url = ""
|
||||||
if "HTTP_REFERER" in request.META:
|
if "HTTP_REFERER" in request.META:
|
||||||
|
@ -33,25 +35,25 @@ def back(context):
|
||||||
@register.filter("fieldtype")
|
@register.filter("fieldtype")
|
||||||
def fieldtype(field):
|
def fieldtype(field):
|
||||||
"""Return classname"""
|
"""Return classname"""
|
||||||
# if issubclass(field.__class__, CastableModel):
|
|
||||||
# field = field.cast()
|
|
||||||
if isinstance(field.__class__, Model) or issubclass(field.__class__, Model):
|
if isinstance(field.__class__, Model) or issubclass(field.__class__, Model):
|
||||||
return field._meta.verbose_name
|
return field._meta.verbose_name
|
||||||
return field.__class__.__name__
|
return field.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def title(context, *title):
|
def title(context: Context, *title) -> str:
|
||||||
"""Return either just branding or title - branding"""
|
"""Return either just branding or title - branding"""
|
||||||
branding = CONFIG.y("passbook.branding", "passbook")
|
branding = CONFIG.y("passbook.branding", "passbook")
|
||||||
if not title:
|
if not title:
|
||||||
return branding
|
return branding
|
||||||
|
if "request" not in context:
|
||||||
|
return ""
|
||||||
|
resolver_match = context.request.resolver_match
|
||||||
|
if not resolver_match:
|
||||||
|
return ""
|
||||||
# Include App Title in title
|
# Include App Title in title
|
||||||
app = ""
|
app = ""
|
||||||
if (
|
if resolver_match.namespace != "":
|
||||||
context.request.resolver_match
|
|
||||||
and context.request.resolver_match.namespace != ""
|
|
||||||
):
|
|
||||||
dj_app = None
|
dj_app = None
|
||||||
namespace = context.request.resolver_match.namespace.split(":")[0]
|
namespace = context.request.resolver_match.namespace.split(":")[0]
|
||||||
# New label (App URL Namespace == App Label)
|
# New label (App URL Namespace == App Label)
|
||||||
|
|
Reference in New Issue