Adding licenses to files and fixing some pyflakes errors

remotes/origin/issue/4217/improving-mail-design
Jesús Espino 2017-03-03 08:13:12 +01:00
parent c90460f283
commit 16caedce81
21 changed files with 155 additions and 39 deletions

View File

@ -20,10 +20,8 @@ from taiga.base.api import viewsets
from taiga.base import response from taiga.base import response
from taiga.base import exceptions as exc from taiga.base import exceptions as exc
from taiga.base.decorators import list_route from taiga.base.decorators import list_route
from taiga.users.models import AuthData, User
from taiga.users.services import get_user_photo_url from taiga.users.services import get_user_photo_url
from taiga.users.gravatar import get_user_gravatar_id from taiga.users.gravatar import get_user_gravatar_id
from taiga.projects.serializers import ProjectSerializer
from taiga.importers import permissions, exceptions from taiga.importers import permissions, exceptions
from taiga.importers.services import resolve_users_bindings from taiga.importers.services import resolve_users_bindings

View File

@ -1,6 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import requests import requests
import asana import asana
import json
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType

View File

@ -44,7 +44,7 @@ def import_project(self, user_id, token, project_id, options):
"project": project_id, "project": project_id,
"exception": e "exception": e
} }
email = mail_builder.importer_import_error(admin, ctx) email = mail_builder.importer_import_error(user, ctx)
email.send() email.send()
logger.error('Error importing Asana project %s (by %s)', project_id, user, exc_info=sys.exc_info()) logger.error('Error importing Asana project %s (by %s)', project_id, user, exc_info=sys.exc_info())
else: else:

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
class InvalidRequest(Exception): class InvalidRequest(Exception):
pass pass

View File

@ -20,10 +20,8 @@ from taiga.base.api import viewsets
from taiga.base import response from taiga.base import response
from taiga.base import exceptions as exc from taiga.base import exceptions as exc
from taiga.base.decorators import list_route from taiga.base.decorators import list_route
from taiga.users.models import AuthData, User
from taiga.users.services import get_user_photo_url from taiga.users.services import get_user_photo_url
from taiga.users.gravatar import get_user_gravatar_id from taiga.users.gravatar import get_user_gravatar_id
from taiga.projects.serializers import ProjectSerializer
from taiga.importers import permissions from taiga.importers import permissions
from taiga.importers import exceptions from taiga.importers import exceptions

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import requests import requests
from urllib.parse import parse_qsl from urllib.parse import parse_qsl
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
@ -19,7 +37,7 @@ from taiga.timeline.rebuilder import rebuild_timeline
from taiga.timeline.models import Timeline from taiga.timeline.models import Timeline
from taiga.users.models import User, AuthData from taiga.users.models import User, AuthData
from taiga.importers.exceptions import InvalidAuthResult from taiga.importers.exceptions import InvalidAuthResult, FailedRequest
class GithubClient: class GithubClient:

View File

@ -44,7 +44,7 @@ def import_project(self, user_id, token, project_id, options):
"project": project_id, "project": project_id,
"exception": e "exception": e
} }
email = mail_builder.importer_import_error(admin, ctx) email = mail_builder.importer_import_error(user, ctx)
email.send() email.send()
logger.error('Error importing GitHub project %s (by %s)', project_id, user, exc_info=sys.exc_info()) logger.error('Error importing GitHub project %s (by %s)', project_id, user, exc_info=sys.exc_info())
else: else:

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import datetime import datetime
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import requests import requests
from urllib.parse import parse_qsl from urllib.parse import parse_qsl
from oauthlib.oauth1 import SIGNATURE_RSA from oauthlib.oauth1 import SIGNATURE_RSA
@ -7,7 +25,7 @@ from django.core.files.base import ContentFile
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from taiga.users.models import User from taiga.users.models import User
from taiga.projects.models import Project, ProjectTemplate, Membership, Points from taiga.projects.models import Points
from taiga.projects.userstories.models import UserStory from taiga.projects.userstories.models import UserStory
from taiga.projects.tasks.models import Task from taiga.projects.tasks.models import Task
from taiga.projects.issues.models import Issue from taiga.projects.issues.models import Issue

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
from collections import OrderedDict from collections import OrderedDict
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify

View File

@ -21,11 +21,8 @@ from django.conf import settings
from django.db.models import Q from django.db.models import Q
from taiga.importers.asana.importer import AsanaImporter from taiga.importers.asana.importer import AsanaImporter
from taiga.users.models import User, AuthData from taiga.users.models import User
from taiga.projects.services import projects as service
import unittest.mock
import timeit
import json import json

View File

@ -21,11 +21,7 @@ from django.conf import settings
from django.db.models import Q from django.db.models import Q
from taiga.importers.github.importer import GithubImporter from taiga.importers.github.importer import GithubImporter
from taiga.users.models import User, AuthData from taiga.users.models import User
from taiga.projects.services import projects as service
import unittest.mock
import timeit
class Command(BaseCommand): class Command(BaseCommand):
@ -57,8 +53,8 @@ class Command(BaseCommand):
print("Go to here and come with your code (in the redirected url): {}".format(url)) print("Go to here and come with your code (in the redirected url): {}".format(url))
code = input("Code: ") code = input("Code: ")
access_data = GithubImporter.get_access_token( access_data = GithubImporter.get_access_token(
settings.IMPORTERS.get('github', {}).get('client_id', None) settings.IMPORTERS.get('github', {}).get('client_id', None),
settings.IMPORTERS.get('github', {}).get('client_secret', None) settings.IMPORTERS.get('github', {}).get('client_secret', None),
code code
) )
token = access_data token = access_data

View File

@ -23,10 +23,7 @@ from django.conf import settings
from taiga.importers.jira.agile import JiraAgileImporter from taiga.importers.jira.agile import JiraAgileImporter
from taiga.importers.jira.normal import JiraNormalImporter from taiga.importers.jira.normal import JiraNormalImporter
from taiga.users.models import User from taiga.users.models import User
from taiga.projects.services import projects as service
import unittest.mock
import timeit
import json import json
@ -69,7 +66,7 @@ class Command(BaseCommand):
True True
) )
print(url) print(url)
code = input("Go to the url and get back the code") input("Go to the url, allow the user and get back and press enter")
token = JiraNormalImporter.get_access_token( token = JiraNormalImporter.get_access_token(
server, server,
settings.IMPORTERS.get('jira', {}).get('consumer_key', None), settings.IMPORTERS.get('jira', {}).get('consumer_key', None),

View File

@ -21,10 +21,6 @@ from django.db.models import Q
from taiga.importers.pivotal import PivotalImporter from taiga.importers.pivotal import PivotalImporter
from taiga.users.models import User from taiga.users.models import User
from taiga.projects.services import projects as service
import unittest.mock
import timeit
class Command(BaseCommand): class Command(BaseCommand):

View File

@ -21,10 +21,6 @@ from django.db.models import Q
from taiga.importers.trello.importer import TrelloImporter from taiga.importers.trello.importer import TrelloImporter
from taiga.users.models import User from taiga.users.models import User
from taiga.projects.services import projects as service
import unittest.mock
import timeit
class Command(BaseCommand): class Command(BaseCommand):

View File

@ -16,10 +16,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/>.
from taiga.base.api.permissions import TaigaResourcePermission, AllowAny, IsAuthenticated from taiga.base.api.permissions import TaigaResourcePermission, IsAuthenticated
from taiga.base.api.permissions import IsSuperUser, HasProjectPerm, IsProjectAdmin
from taiga.permissions.permissions import CommentAndOrUpdatePerm
class ImporterPermission(TaigaResourcePermission): class ImporterPermission(TaigaResourcePermission):

View File

@ -23,7 +23,6 @@ from taiga.base.decorators import list_route
from taiga.users.models import AuthData, User from taiga.users.models import AuthData, User
from taiga.users.services import get_user_photo_url from taiga.users.services import get_user_photo_url
from taiga.users.gravatar import get_user_gravatar_id from taiga.users.gravatar import get_user_gravatar_id
from taiga.projects.serializers import ProjectSerializer
from taiga.importers import permissions from taiga.importers import permissions
from .importer import PivotalImporter from .importer import PivotalImporter

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
import requests import requests

View File

@ -44,7 +44,7 @@ def import_project(self, user_id, token, project_id, options):
"project": project_id, "project": project_id,
"exception": e "exception": e
} }
email = mail_builder.importer_import_error(admin, ctx) email = mail_builder.importer_import_error(user, ctx)
email.send() email.send()
logger.error('Error importing PivotalTracker project %s (by %s)', project_id, user, exc_info=sys.exc_info()) logger.error('Error importing PivotalTracker project %s (by %s)', project_id, user, exc_info=sys.exc_info())
else: else:

View File

@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2017 Andrey Antukh <niwi@niwi.nz>
# Copyright (C) 2014-2017 Jesús Espino <jespinog@gmail.com>
# Copyright (C) 2014-2017 David Barragán <bameda@dbarragan.com>
# Copyright (C) 2014-2017 Alejandro Alonso <alejandro.alonso@kaleidos.net>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
from taiga.users.models import User from taiga.users.models import User

View File

@ -25,7 +25,6 @@ from taiga.base.decorators import list_route
from taiga.users.models import AuthData, User from taiga.users.models import AuthData, User
from taiga.users.services import get_user_photo_url from taiga.users.services import get_user_photo_url
from taiga.users.gravatar import get_user_gravatar_id from taiga.users.gravatar import get_user_gravatar_id
from taiga.projects.serializers import ProjectSerializer
from .importer import TrelloImporter from .importer import TrelloImporter
from taiga.importers import permissions from taiga.importers import permissions