Some flake8 fixes
parent
3ba3c8978b
commit
47c338324e
|
@ -27,8 +27,6 @@ from taiga.base.decorators import list_route
|
||||||
from taiga.base import exceptions as exc
|
from taiga.base import exceptions as exc
|
||||||
from taiga.base import response
|
from taiga.base import response
|
||||||
|
|
||||||
from taiga.users.services import get_and_validate_user
|
|
||||||
|
|
||||||
from .serializers import PublicRegisterSerializer
|
from .serializers import PublicRegisterSerializer
|
||||||
from .serializers import PrivateRegisterForExistingUserSerializer
|
from .serializers import PrivateRegisterForExistingUserSerializer
|
||||||
from .serializers import PrivateRegisterForNewUserSerializer
|
from .serializers import PrivateRegisterForNewUserSerializer
|
||||||
|
|
|
@ -32,7 +32,6 @@ selfcontained tokens. This trust tokes from external
|
||||||
fraudulent modifications.
|
fraudulent modifications.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import base64
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -40,6 +39,7 @@ from rest_framework.authentication import BaseAuthentication
|
||||||
|
|
||||||
from .tokens import get_user_for_token
|
from .tokens import get_user_for_token
|
||||||
|
|
||||||
|
|
||||||
class Session(BaseAuthentication):
|
class Session(BaseAuthentication):
|
||||||
"""
|
"""
|
||||||
Session based authentication like the standard
|
Session based authentication like the standard
|
||||||
|
|
|
@ -19,6 +19,7 @@ from taiga.base import exceptions as exc
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.core import signing
|
from django.core import signing
|
||||||
|
|
||||||
|
|
||||||
def get_token_for_user(user, scope):
|
def get_token_for_user(user, scope):
|
||||||
"""
|
"""
|
||||||
Generate a new signed token containing
|
Generate a new signed token containing
|
||||||
|
|
|
@ -19,13 +19,11 @@
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.paginator import Paginator, InvalidPage
|
from django.core.paginator import Paginator, InvalidPage
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from rest_framework import exceptions
|
|
||||||
from rest_framework.request import clone_request
|
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
@ -193,16 +191,16 @@ class GenericAPIView(views.APIView):
|
||||||
"""
|
"""
|
||||||
filter_backends = self.filter_backends or []
|
filter_backends = self.filter_backends or []
|
||||||
if not filter_backends and hasattr(self, 'filter_backend'):
|
if not filter_backends and hasattr(self, 'filter_backend'):
|
||||||
raise RuntimeException('The `filter_backend` attribute and `FILTER_BACKEND` setting '
|
raise RuntimeError('The `filter_backend` attribute and `FILTER_BACKEND` setting '
|
||||||
'are due to be deprecated in favor of a `filter_backends` '
|
'are due to be deprecated in favor of a `filter_backends` '
|
||||||
'attribute and `DEFAULT_FILTER_BACKENDS` setting, that take '
|
'attribute and `DEFAULT_FILTER_BACKENDS` setting, that take '
|
||||||
'a *list* of filter backend classes.')
|
'a *list* of filter backend classes.')
|
||||||
return filter_backends
|
return filter_backends
|
||||||
|
|
||||||
|
###########################################################
|
||||||
########################
|
# The following methods provide default implementations #
|
||||||
### The following methods provide default implementations
|
# that you may want to override for more complex cases. #
|
||||||
### that you may want to override for more complex cases.
|
###########################################################
|
||||||
|
|
||||||
def get_paginate_by(self, queryset=None):
|
def get_paginate_by(self, queryset=None):
|
||||||
"""
|
"""
|
||||||
|
@ -214,7 +212,7 @@ class GenericAPIView(views.APIView):
|
||||||
Otherwise defaults to using `self.paginate_by`.
|
Otherwise defaults to using `self.paginate_by`.
|
||||||
"""
|
"""
|
||||||
if queryset is not None:
|
if queryset is not None:
|
||||||
raise RuntimeException('The `queryset` parameter to `get_paginate_by()` '
|
raise RuntimeError('The `queryset` parameter to `get_paginate_by()` '
|
||||||
'is due to be deprecated.')
|
'is due to be deprecated.')
|
||||||
if self.paginate_by_param:
|
if self.paginate_by_param:
|
||||||
try:
|
try:
|
||||||
|
@ -263,8 +261,7 @@ class GenericAPIView(views.APIView):
|
||||||
if self.model is not None:
|
if self.model is not None:
|
||||||
return self.model._default_manager.all()
|
return self.model._default_manager.all()
|
||||||
|
|
||||||
raise ImproperlyConfigured("'%s' must define 'queryset' or 'model'"
|
raise ImproperlyConfigured("'%s' must define 'queryset' or 'model'" % self.__class__.__name__)
|
||||||
% self.__class__.__name__)
|
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
"""
|
"""
|
||||||
|
@ -280,7 +277,7 @@ class GenericAPIView(views.APIView):
|
||||||
else:
|
else:
|
||||||
# NOTE: explicit exception for avoid and fix
|
# NOTE: explicit exception for avoid and fix
|
||||||
# usage of deprecated way of get_object
|
# usage of deprecated way of get_object
|
||||||
raise RuntimeException("DEPRECATED")
|
raise RuntimeError("DEPRECATED")
|
||||||
|
|
||||||
# Perform the lookup filtering.
|
# Perform the lookup filtering.
|
||||||
# Note that `pk` and `slug` are deprecated styles of lookup filtering.
|
# Note that `pk` and `slug` are deprecated styles of lookup filtering.
|
||||||
|
@ -292,10 +289,10 @@ class GenericAPIView(views.APIView):
|
||||||
if lookup is not None:
|
if lookup is not None:
|
||||||
filter_kwargs = {self.lookup_field: lookup}
|
filter_kwargs = {self.lookup_field: lookup}
|
||||||
elif pk is not None and self.lookup_field == 'pk':
|
elif pk is not None and self.lookup_field == 'pk':
|
||||||
raise RuntimeException('The `pk_url_kwarg` attribute is due to be deprecated. '
|
raise RuntimeError('The `pk_url_kwarg` attribute is due to be deprecated. '
|
||||||
'Use the `lookup_field` attribute instead')
|
'Use the `lookup_field` attribute instead')
|
||||||
elif slug is not None and self.lookup_field == 'pk':
|
elif slug is not None and self.lookup_field == 'pk':
|
||||||
raise RuntimeException('The `slug_url_kwarg` attribute is due to be deprecated. '
|
raise RuntimeError('The `slug_url_kwarg` attribute is due to be deprecated. '
|
||||||
'Use the `lookup_field` attribute instead')
|
'Use the `lookup_field` attribute instead')
|
||||||
else:
|
else:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
|
@ -314,12 +311,13 @@ class GenericAPIView(views.APIView):
|
||||||
except Http404:
|
except Http404:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
########################
|
###################################################
|
||||||
### The following are placeholder methods,
|
# The following are placeholder methods, #
|
||||||
### and are intended to be overridden.
|
# and are intended to be overridden. #
|
||||||
###
|
# #
|
||||||
### The are not called by GenericAPIView directly,
|
# The are not called by GenericAPIView directly, #
|
||||||
### but are used by the mixin methods.
|
# but are used by the mixin methods. #
|
||||||
|
###################################################
|
||||||
|
|
||||||
def pre_conditions_on_save(self, obj):
|
def pre_conditions_on_save(self, obj):
|
||||||
"""
|
"""
|
||||||
|
@ -363,11 +361,11 @@ class GenericAPIView(views.APIView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
##########################################################
|
######################################################
|
||||||
### Concrete view classes that provide method handlers ###
|
# Concrete view classes that provide method handlers #
|
||||||
### by composing the mixin classes with the base view. ###
|
# by composing the mixin classes with the base view. #
|
||||||
### NOTE: not used by taiga. ###
|
# NOTE: not used by taiga. #
|
||||||
##########################################################
|
######################################################
|
||||||
|
|
||||||
class CreateAPIView(mixins.CreateModelMixin,
|
class CreateAPIView(mixins.CreateModelMixin,
|
||||||
GenericAPIView):
|
GenericAPIView):
|
||||||
|
|
|
@ -219,8 +219,10 @@ class IsObjectOwner(PermissionComponent):
|
||||||
class AllowAnyPermission(ResourcePermission):
|
class AllowAnyPermission(ResourcePermission):
|
||||||
enought_perms = AllowAny()
|
enought_perms = AllowAny()
|
||||||
|
|
||||||
|
|
||||||
class IsAuthenticatedPermission(ResourcePermission):
|
class IsAuthenticatedPermission(ResourcePermission):
|
||||||
enought_perms = IsAuthenticated()
|
enought_perms = IsAuthenticated()
|
||||||
|
|
||||||
|
|
||||||
class TaigaResourcePermission(ResourcePermission):
|
class TaigaResourcePermission(ResourcePermission):
|
||||||
enought_perms = IsSuperUser()
|
enought_perms = IsSuperUser()
|
||||||
|
|
|
@ -56,6 +56,7 @@ def get_view_name(view_cls, suffix=None):
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
def get_view_description(view_cls, html=False):
|
def get_view_description(view_cls, html=False):
|
||||||
"""
|
"""
|
||||||
Given a view class, return a textual description to represent the view.
|
Given a view class, return a textual description to represent the view.
|
||||||
|
@ -141,7 +142,6 @@ class APIView(View):
|
||||||
headers['Vary'] = 'Accept'
|
headers['Vary'] = 'Accept'
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
|
|
||||||
def http_method_not_allowed(self, request, *args, **kwargs):
|
def http_method_not_allowed(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
If `request.method` does not correspond to a handler method,
|
If `request.method` does not correspond to a handler method,
|
||||||
|
@ -445,7 +445,7 @@ class APIView(View):
|
||||||
|
|
||||||
|
|
||||||
def api_server_error(request, *args, **kwargs):
|
def api_server_error(request, *args, **kwargs):
|
||||||
if settings.DEBUG == False and request.META['CONTENT_TYPE'] == "application/json":
|
if settings.DEBUG is False and request.META['CONTENT_TYPE'] == "application/json":
|
||||||
return HttpResponse(json.dumps({"error": "Server application error"}),
|
return HttpResponse(json.dumps({"error": "Server application error"}),
|
||||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||||
return server_error(request, *args, **kwargs)
|
return server_error(request, *args, **kwargs)
|
||||||
|
|
|
@ -124,6 +124,7 @@ class GenericViewSet(ViewSetMixin, generics.GenericAPIView):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ReadOnlyListViewSet(pagination.HeadersPaginationMixin,
|
class ReadOnlyListViewSet(pagination.HeadersPaginationMixin,
|
||||||
pagination.ConditionalPaginationMixin,
|
pagination.ConditionalPaginationMixin,
|
||||||
GenericViewSet):
|
GenericViewSet):
|
||||||
|
@ -132,6 +133,7 @@ class ReadOnlyListViewSet(pagination.HeadersPaginationMixin,
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ReadOnlyModelViewSet(mixins.RetrieveModelMixin,
|
class ReadOnlyModelViewSet(mixins.RetrieveModelMixin,
|
||||||
mixins.ListModelMixin,
|
mixins.ListModelMixin,
|
||||||
GenericViewSet):
|
GenericViewSet):
|
||||||
|
|
|
@ -20,6 +20,7 @@ import sys
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from . import monkey
|
from . import monkey
|
||||||
|
|
||||||
|
|
||||||
class BaseAppConfig(AppConfig):
|
class BaseAppConfig(AppConfig):
|
||||||
name = "taiga.base"
|
name = "taiga.base"
|
||||||
verbose_name = "Base App Config"
|
verbose_name = "Base App Config"
|
||||||
|
@ -28,4 +29,3 @@ class BaseAppConfig(AppConfig):
|
||||||
print("Monkey patching...", file=sys.stderr)
|
print("Monkey patching...", file=sys.stderr)
|
||||||
monkey.patch_restframework()
|
monkey.patch_restframework()
|
||||||
monkey.patch_serializer()
|
monkey.patch_serializer()
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ from taiga.base.exceptions import BaseException
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class ConnectorBaseException(BaseException):
|
class ConnectorBaseException(BaseException):
|
||||||
status_code = 400
|
status_code = 400
|
||||||
default_detail = _("Connection error.")
|
default_detail = _("Connection error.")
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
## Rest Framework 2.4 backport some decorators.
|
# Rest Framework 2.4 backport some decorators.
|
||||||
|
|
||||||
def detail_route(methods=['get'], **kwargs):
|
def detail_route(methods=['get'], **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -51,12 +51,14 @@ def link(**kwargs):
|
||||||
"""
|
"""
|
||||||
msg = 'link is pending deprecation. Use detail_route instead.'
|
msg = 'link is pending deprecation. Use detail_route instead.'
|
||||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
func.bind_to_methods = ['get']
|
func.bind_to_methods = ['get']
|
||||||
func.detail = True
|
func.detail = True
|
||||||
func.permission_classes = kwargs.get('permission_classes', [])
|
func.permission_classes = kwargs.get('permission_classes', [])
|
||||||
func.kwargs = kwargs
|
func.kwargs = kwargs
|
||||||
return func
|
return func
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,10 +68,12 @@ def action(methods=['post'], **kwargs):
|
||||||
"""
|
"""
|
||||||
msg = 'action is pending deprecation. Use detail_route instead.'
|
msg = 'action is pending deprecation. Use detail_route instead.'
|
||||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
func.bind_to_methods = methods
|
func.bind_to_methods = methods
|
||||||
func.detail = True
|
func.detail = True
|
||||||
func.permission_classes = kwargs.get('permission_classes', [])
|
func.permission_classes = kwargs.get('permission_classes', [])
|
||||||
func.kwargs = kwargs
|
func.kwargs = kwargs
|
||||||
return func
|
return func
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
|
@ -23,7 +23,6 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
|
||||||
from taiga.base import response
|
from taiga.base import response
|
||||||
from taiga.base.utils.json import to_json
|
|
||||||
|
|
||||||
|
|
||||||
class BaseException(exceptions.APIException):
|
class BaseException(exceptions.APIException):
|
||||||
|
|
|
@ -102,7 +102,8 @@ class PermissionBasedFilterBackend(FilterBackend):
|
||||||
project_id = int(request.QUERY_PARAMS["project"])
|
project_id = int(request.QUERY_PARAMS["project"])
|
||||||
except:
|
except:
|
||||||
logger.error("Filtering project diferent value than an integer: {}".format(
|
logger.error("Filtering project diferent value than an integer: {}".format(
|
||||||
request.QUERY_PARAMS["project"]))
|
request.QUERY_PARAMS["project"]
|
||||||
|
))
|
||||||
raise exc.BadRequest("'project' must be an integer value.")
|
raise exc.BadRequest("'project' must be an integer value.")
|
||||||
|
|
||||||
qs = queryset
|
qs = queryset
|
||||||
|
@ -190,7 +191,8 @@ class CanViewProjectObjFilterBackend(FilterBackend):
|
||||||
project_id = int(request.QUERY_PARAMS["project"])
|
project_id = int(request.QUERY_PARAMS["project"])
|
||||||
except:
|
except:
|
||||||
logger.error("Filtering project diferent value than an integer: {}".format(
|
logger.error("Filtering project diferent value than an integer: {}".format(
|
||||||
request.QUERY_PARAMS["project"]))
|
request.QUERY_PARAMS["project"]
|
||||||
|
))
|
||||||
raise exc.BadRequest("'project' must be an integer value.")
|
raise exc.BadRequest("'project' must be an integer value.")
|
||||||
|
|
||||||
qs = queryset
|
qs = queryset
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.db.models.loading import get_model
|
from django.db.models.loading import get_model
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from djmail.template_mail import MagicMailBuilder, InlineCSSTemplateMail
|
from djmail.template_mail import MagicMailBuilder, InlineCSSTemplateMail
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from django import http
|
from django import http
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys
|
|
||||||
|
|
||||||
def patch_serializer():
|
def patch_serializer():
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
|
@ -15,10 +15,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from django.db.models import Q
|
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
|
||||||
Neighbor = namedtuple("Neighbor", "left right")
|
Neighbor = namedtuple("Neighbor", "left right")
|
||||||
|
|
|
@ -19,6 +19,7 @@ from django.core.files import storage
|
||||||
|
|
||||||
import django_sites as sites
|
import django_sites as sites
|
||||||
|
|
||||||
|
|
||||||
class FileSystemStorage(storage.FileSystemStorage):
|
class FileSystemStorage(storage.FileSystemStorage):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re
|
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
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 _
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ def get_typename_for_model_class(model:object, for_concrete_model=True) -> str:
|
||||||
|
|
||||||
return "{0}.{1}".format(model._meta.app_label, model._meta.model_name)
|
return "{0}.{1}".format(model._meta.app_label, model._meta.model_name)
|
||||||
|
|
||||||
|
|
||||||
def get_typename_for_model_instance(model_instance):
|
def get_typename_for_model_instance(model_instance):
|
||||||
"""
|
"""
|
||||||
Get content type tuple from model instance.
|
Get content type tuple from model instance.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
|
||||||
def dict_sum(*args):
|
def dict_sum(*args):
|
||||||
result = collections.Counter()
|
result = collections.Counter()
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
def noop(*args, **kwargs):
|
def noop(*args, **kwargs):
|
||||||
"""The noop function."""
|
"""The noop function."""
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -22,6 +22,7 @@ from django.utils.encoding import force_text
|
||||||
def dumps(data, ensure_ascii=True, encoder_class=encoders.JSONEncoder):
|
def dumps(data, ensure_ascii=True, encoder_class=encoders.JSONEncoder):
|
||||||
return json.dumps(data, cls=encoder_class, indent=None, ensure_ascii=ensure_ascii)
|
return json.dumps(data, cls=encoder_class, indent=None, ensure_ascii=ensure_ascii)
|
||||||
|
|
||||||
|
|
||||||
def loads(data):
|
def loads(data):
|
||||||
if isinstance(data, bytes):
|
if isinstance(data, bytes):
|
||||||
data = force_text(data)
|
data = force_text(data)
|
||||||
|
|
|
@ -20,6 +20,7 @@ def first(iterable):
|
||||||
return None
|
return None
|
||||||
return iterable[0]
|
return iterable[0]
|
||||||
|
|
||||||
|
|
||||||
def next(data:list):
|
def next(data:list):
|
||||||
return data[1:]
|
return data[1:]
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,3 @@ def without_signals(*disablers):
|
||||||
for disabler in disablers:
|
for disabler in disablers:
|
||||||
signal, *ids = disabler
|
signal, *ids = disabler
|
||||||
signal.receivers = signal.backup_receivers
|
signal.receivers = signal.backup_receivers
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.utils import baseconv
|
|
||||||
from django.template.defaultfilters import slugify as django_slugify
|
from django.template.defaultfilters import slugify as django_slugify
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
|
@ -30,8 +30,8 @@ def get_current_session_id() -> str:
|
||||||
|
|
||||||
global _local
|
global _local
|
||||||
if not hasattr(_local, "session_id"):
|
if not hasattr(_local, "session_id"):
|
||||||
raise RuntimeException("No session identifier is found, "
|
raise RuntimeError("No session identifier is found, "
|
||||||
"ara you sure that session id middleware "
|
"are you sure that session id middleware "
|
||||||
"is active?")
|
"is active?")
|
||||||
return _local.session_id
|
return _local.session_id
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,6 @@ from django.conf import settings
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
|
||||||
from rest_framework.decorators import throttle_classes
|
|
||||||
|
|
||||||
from taiga.base.decorators import detail_route, list_route
|
from taiga.base.decorators import detail_route, list_route
|
||||||
from taiga.base import exceptions as exc
|
from taiga.base import exceptions as exc
|
||||||
from taiga.base import response
|
from taiga.base import response
|
||||||
|
@ -187,7 +185,6 @@ class ProjectImporterViewSet(mixins.ImportThrottlingPolicyMixin, CreateModelMixi
|
||||||
response_data = ProjectSerializer(project).data
|
response_data = ProjectSerializer(project).data
|
||||||
return response.Created(response_data)
|
return response.Created(response_data)
|
||||||
|
|
||||||
|
|
||||||
@detail_route(methods=['post'])
|
@detail_route(methods=['post'])
|
||||||
@method_decorator(atomic)
|
@method_decorator(atomic)
|
||||||
def issue(self, request, *args, **kwargs):
|
def issue(self, request, *args, **kwargs):
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.db.models import signals
|
|
||||||
|
|
||||||
from taiga.projects.models import Membership
|
from taiga.projects.models import Membership
|
||||||
|
|
||||||
from . import serializers
|
from . import serializers
|
||||||
|
|
|
@ -14,19 +14,19 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import signals
|
from django.db.models import signals
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import pprint
|
|
||||||
|
|
||||||
from taiga.projects.models import Project
|
from taiga.projects.models import Project
|
||||||
from taiga.export_import.renderers import ExportRenderer
|
from taiga.export_import.renderers import ExportRenderer
|
||||||
from taiga.export_import.dump_service import dict_to_project, TaigaImportError
|
from taiga.export_import.dump_service import dict_to_project, TaigaImportError
|
||||||
from taiga.export_import.service import get_errors
|
from taiga.export_import.service import get_errors
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
args = '<dump_file> <owner-email>'
|
args = '<dump_file> <owner-email>'
|
||||||
help = 'Export a project to json'
|
help = 'Export a project to json'
|
||||||
|
|
|
@ -16,5 +16,6 @@
|
||||||
|
|
||||||
from rest_framework.renderers import UnicodeJSONRenderer
|
from rest_framework.renderers import UnicodeJSONRenderer
|
||||||
|
|
||||||
|
|
||||||
class ExportRenderer(UnicodeJSONRenderer):
|
class ExportRenderer(UnicodeJSONRenderer):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -53,7 +53,6 @@ def dump_project(self, user, project):
|
||||||
email.send()
|
email.send()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
deletion_date = timezone.now() + datetime.timedelta(seconds=settings.EXPORTS_TTL)
|
deletion_date = timezone.now() + datetime.timedelta(seconds=settings.EXPORTS_TTL)
|
||||||
ctx = {
|
ctx = {
|
||||||
"url": url,
|
"url": url,
|
||||||
|
|
|
@ -20,5 +20,6 @@ from taiga.base import throttling
|
||||||
class ImportModeRateThrottle(throttling.UserRateThrottle):
|
class ImportModeRateThrottle(throttling.UserRateThrottle):
|
||||||
scope = "import-mode"
|
scope = "import-mode"
|
||||||
|
|
||||||
|
|
||||||
class ImportDumpModeRateThrottle(throttling.UserRateThrottle):
|
class ImportDumpModeRateThrottle(throttling.UserRateThrottle):
|
||||||
scope = "import-dump-mode"
|
scope = "import-dump-mode"
|
||||||
|
|
|
@ -61,7 +61,7 @@ class BitBucketViewSet(BaseWebhookApiViewSet):
|
||||||
valid_origin_ips = bitbucket_config.get("valid_origin_ips",
|
valid_origin_ips = bitbucket_config.get("valid_origin_ips",
|
||||||
settings.BITBUCKET_VALID_ORIGIN_IPS)
|
settings.BITBUCKET_VALID_ORIGIN_IPS)
|
||||||
origin_ip = get_real_ip(request)
|
origin_ip = get_real_ip(request)
|
||||||
if valid_origin_ips and (not origin_ip or not origin_ip in valid_origin_ips):
|
if valid_origin_ips and (not origin_ip or origin_ip not in valid_origin_ips):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return project_secret == secret_key
|
return project_secret == secret_key
|
||||||
|
|
|
@ -15,12 +15,11 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from taiga.base import exceptions as exc
|
from taiga.base import exceptions as exc
|
||||||
from taiga.projects.models import Project, IssueStatus, TaskStatus, UserStoryStatus
|
from taiga.projects.models import IssueStatus, TaskStatus, UserStoryStatus
|
||||||
from taiga.projects.issues.models import Issue
|
from taiga.projects.issues.models import Issue
|
||||||
from taiga.projects.tasks.models import Task
|
from taiga.projects.tasks.models import Task
|
||||||
from taiga.projects.userstories.models import UserStory
|
from taiga.projects.userstories.models import UserStory
|
||||||
|
@ -33,6 +32,7 @@ from .services import get_bitbucket_user
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class PushEventHook(BaseEventHook):
|
class PushEventHook(BaseEventHook):
|
||||||
def process_event(self):
|
def process_event(self):
|
||||||
if self.payload is None:
|
if self.payload is None:
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import migrations
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
def create_github_system_user(apps, schema_editor):
|
def create_github_system_user(apps, schema_editor):
|
||||||
# We get the model from the versioned app registry;
|
# We get the model from the versioned app registry;
|
||||||
# if we directly import it, it'll be the wrong version
|
# if we directly import it, it'll be the wrong version
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from taiga.projects.models import Project, IssueStatus, TaskStatus, UserStoryStatus
|
from taiga.projects.models import IssueStatus, TaskStatus, UserStoryStatus
|
||||||
|
|
||||||
from taiga.projects.issues.models import Issue
|
from taiga.projects.issues.models import Issue
|
||||||
from taiga.projects.tasks.models import Task
|
from taiga.projects.tasks.models import Task
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import migrations
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
def create_github_system_user(apps, schema_editor):
|
def create_github_system_user(apps, schema_editor):
|
||||||
# We get the model from the versioned app registry;
|
# We get the model from the versioned app registry;
|
||||||
# if we directly import it, it'll be the wrong version
|
# if we directly import it, it'll be the wrong version
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from ipware.ip import get_real_ip
|
from ipware.ip import get_real_ip
|
||||||
|
|
|
@ -19,7 +19,7 @@ import os
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from taiga.projects.models import Project, IssueStatus, TaskStatus, UserStoryStatus
|
from taiga.projects.models import IssueStatus, TaskStatus, UserStoryStatus
|
||||||
|
|
||||||
from taiga.projects.issues.models import Issue
|
from taiga.projects.issues.models import Issue
|
||||||
from taiga.projects.tasks.models import Task
|
from taiga.projects.tasks.models import Task
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import migrations
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
def create_github_system_user(apps, schema_editor):
|
def create_github_system_user(apps, schema_editor):
|
||||||
# We get the model from the versioned app registry;
|
# We get the model from the versioned app registry;
|
||||||
# if we directly import it, it'll be the wrong version
|
# if we directly import it, it'll be the wrong version
|
||||||
|
|
|
@ -26,6 +26,7 @@ from taiga.base.utils.slug import slugify
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class WikiLinkExtension(Extension):
|
class WikiLinkExtension(Extension):
|
||||||
def __init__(self, project, *args, **kwargs):
|
def __init__(self, project, *args, **kwargs):
|
||||||
self.project = project
|
self.project = project
|
||||||
|
@ -66,6 +67,7 @@ class WikiLinksPattern(Pattern):
|
||||||
|
|
||||||
SLUG_RE = re.compile(r"^[-a-zA-Z0-9_]+$")
|
SLUG_RE = re.compile(r"^[-a-zA-Z0-9_]+$")
|
||||||
|
|
||||||
|
|
||||||
class RelativeLinksTreeprocessor(Treeprocessor):
|
class RelativeLinksTreeprocessor(Treeprocessor):
|
||||||
def __init__(self, md, project):
|
def __init__(self, md, project):
|
||||||
self.project = project
|
self.project = project
|
||||||
|
|
|
@ -22,6 +22,7 @@ import bleach
|
||||||
import html5lib
|
import html5lib
|
||||||
from html5lib.serializer.htmlserializer import HTMLSerializer
|
from html5lib.serializer.htmlserializer import HTMLSerializer
|
||||||
|
|
||||||
|
|
||||||
def _serialize(domtree):
|
def _serialize(domtree):
|
||||||
walker = html5lib.treewalkers.getTreeWalker('etree')
|
walker = html5lib.treewalkers.getTreeWalker('etree')
|
||||||
stream = walker(domtree)
|
stream = walker(domtree)
|
||||||
|
@ -32,7 +33,7 @@ def _serialize(domtree):
|
||||||
return serializer.render(stream)
|
return serializer.render(stream)
|
||||||
|
|
||||||
bleach._serialize = _serialize
|
bleach._serialize = _serialize
|
||||||
### END PATCH
|
# END PATCH
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.utils.encoding import force_bytes
|
from django.utils.encoding import force_bytes
|
||||||
|
|
|
@ -23,7 +23,6 @@ from taiga.base.api import GenericViewSet
|
||||||
from . import serializers
|
from . import serializers
|
||||||
from . import service
|
from . import service
|
||||||
from . import permissions
|
from . import permissions
|
||||||
from . import models
|
|
||||||
|
|
||||||
|
|
||||||
class TimelineViewSet(GenericViewSet):
|
class TimelineViewSet(GenericViewSet):
|
||||||
|
|
|
@ -36,5 +36,3 @@ class TimelineAppConfig(AppConfig):
|
||||||
sender=apps.get_model("projects", "Membership"))
|
sender=apps.get_model("projects", "Membership"))
|
||||||
signals.post_delete.connect(handlers.delete_membership_push_to_timeline,
|
signals.post_delete.connect(handlers.delete_membership_push_to_timeline,
|
||||||
sender=apps.get_model("projects", "Membership"))
|
sender=apps.get_model("projects", "Membership"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from taiga.base.api.permissions import (TaigaResourcePermission, HasProjectPerm,
|
from taiga.base.api.permissions import (TaigaResourcePermission, HasProjectPerm,
|
||||||
IsProjectOwner, AllowAny)
|
AllowAny)
|
||||||
|
|
||||||
|
|
||||||
class UserTimelinePermission(TaigaResourcePermission):
|
class UserTimelinePermission(TaigaResourcePermission):
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
|
|
||||||
from rest_framework.permissions import IsAuthenticated
|
|
||||||
|
|
||||||
from taiga.base.api import ModelCrudViewSet
|
from taiga.base.api import ModelCrudViewSet
|
||||||
from taiga.base import exceptions as exc
|
from taiga.base import exceptions as exc
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
from taiga.base import filters
|
from taiga.base import filters
|
||||||
|
|
||||||
|
|
||||||
class StorageEntriesFilterBackend(filters.FilterBackend):
|
class StorageEntriesFilterBackend(filters.FilterBackend):
|
||||||
def filter_queryset(self, request, queryset, view):
|
def filter_queryset(self, request, queryset, view):
|
||||||
queryset = super().filter_queryset(request, queryset, view)
|
queryset = super().filter_queryset(request, queryset, view)
|
||||||
|
|
|
@ -14,14 +14,11 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from taiga.base import filters
|
from taiga.base import filters
|
||||||
from taiga.base import response
|
from taiga.base import response
|
||||||
from taiga.base.api import ModelCrudViewSet
|
from taiga.base.api import ModelCrudViewSet
|
||||||
from taiga.base.api import ModelListViewSet
|
from taiga.base.api import ModelListViewSet
|
||||||
|
|
||||||
from taiga.base.api.utils import get_object_or_404
|
|
||||||
from taiga.base.decorators import detail_route
|
from taiga.base.decorators import detail_route
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
|
@ -35,6 +35,7 @@ class HistoryDiffField(serializers.Field):
|
||||||
|
|
||||||
class WebhookSerializer(serializers.ModelSerializer):
|
class WebhookSerializer(serializers.ModelSerializer):
|
||||||
logs_counter = serializers.SerializerMethodField("get_logs_counter")
|
logs_counter = serializers.SerializerMethodField("get_logs_counter")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Webhook
|
model = Webhook
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ class UserSerializer(serializers.Serializer):
|
||||||
def get_name(self, obj):
|
def get_name(self, obj):
|
||||||
return obj.full_name
|
return obj.full_name
|
||||||
|
|
||||||
|
|
||||||
class PointSerializer(serializers.Serializer):
|
class PointSerializer(serializers.Serializer):
|
||||||
id = serializers.SerializerMethodField("get_pk")
|
id = serializers.SerializerMethodField("get_pk")
|
||||||
name = serializers.SerializerMethodField("get_name")
|
name = serializers.SerializerMethodField("get_name")
|
||||||
|
|
|
@ -86,7 +86,7 @@ def _send_request(webhook_id, url, key, data):
|
||||||
duration=0)
|
duration=0)
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
ids = [webhook_log.id for webhook_log in WebhookLog.objects.filter(webhook_id=webhook_id).order_by("-id")[10:]]
|
ids = [log.id for log in WebhookLog.objects.filter(webhook_id=webhook_id).order_by("-id")[10:]]
|
||||||
WebhookLog.objects.filter(id__in=ids).delete()
|
WebhookLog.objects.filter(id__in=ids).delete()
|
||||||
return webhook_log
|
return webhook_log
|
||||||
|
|
||||||
|
@ -135,4 +135,3 @@ def test_webhook(webhook_id, url, key):
|
||||||
data['type'] = "test"
|
data['type'] = "test"
|
||||||
|
|
||||||
return _send_request(webhook_id, url, key, data)
|
return _send_request(webhook_id, url, key, data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue