Adding import finished emails, and fixed tasks from the importer

remotes/origin/issue/4217/improving-mail-design
Jesús Espino 2017-02-27 16:48:49 +01:00
parent 4107231340
commit 0244a39475
21 changed files with 140 additions and 12 deletions

View File

@ -31,7 +31,7 @@ logger = logging.getLogger('taiga.importers.asana')
@app.task(bind=True)
def import_project(self, user_id, token, project_id, options):
user = User.object.get(id=user_id)
user = User.objects.get(id=user_id)
importer = AsanaImporter(user, token)
try:
project = importer.import_project(project_id, options)
@ -44,7 +44,7 @@ def import_project(self, user_id, token, project_id, options):
"project": project_id,
"exception": e
}
email = mail_builder.asana_import_error(admin, ctx)
email = mail_builder.importer_import_error(admin, ctx)
email.send()
logger.error('Error importing Asana project %s (by %s)', project_id, user, exc_info=sys.exc_info())
else:

View File

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

View File

@ -31,7 +31,7 @@ logger = logging.getLogger('taiga.importers.jira')
@app.task(bind=True)
def import_project(self, user_id, url, token, project_id, options, importer_type):
user = User.object.get(id=user_id)
user = User.objects.get(id=user_id)
if importer_type == "agile":
importer = JiraAgileImporter(user, url, token)
@ -49,7 +49,7 @@ def import_project(self, user_id, url, token, project_id, options, importer_type
"project": project_id,
"exception": e
}
email = mail_builder.jira_import_error(admin, ctx)
email = mail_builder.importer_import_error(admin, ctx)
email.send()
logger.error('Error importing Jira project %s (by %s)', project_id, user, exc_info=sys.exc_info())
else:

View File

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

View File

@ -4,13 +4,18 @@ from taiga.users.models import User
def resolve_users_bindings(users_bindings):
new_users_bindings = {}
for key,value in users_bindings.items():
try:
user_key = int(key)
except ValueError:
user_key = key
if isinstance(value, str):
try:
new_users_bindings[int(key)] = User.objects.get(email_iexact=value)
new_users_bindings[user_key] = User.objects.get(email_iexact=value)
except User.MultipleObjectsReturned:
new_users_bindings[int(key)] = User.objects.get(email=value)
new_users_bindings[user_key] = User.objects.get(email=value)
except User.DoesNotExists:
new_users_bindings[int(key)] = None
new_users_bindings[user_key] = None
else:
new_users_bindings[int(key)] = User.objects.get(id=value)
new_users_bindings[user_key] = User.objects.get(id=value)
return new_users_bindings

View File

@ -0,0 +1,11 @@
{% extends "emails/base-body-html.jinja" %}
{% block body %}
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
<h1>Asana Project imported</h1>
<p>Hello {{ user }},</p>
<h3>Your Asana project has been correctly imported.</h3>
<a class="button" href="{{ url }}" title="Go to the project {{ project }}">Go to {{ project }}</a>
<p><small>The Taiga Team</small></p>
{% endtrans %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
Hello {{ user }},
Your Asana project has been correctly imported.
You can see the project {{ project }} here:
{{ url }}
---
The Taiga Team
{% endtrans %}

View File

@ -0,0 +1 @@
{% trans project=project.name|safe %}[{{ project }}] Your Asana project has been imported{% endtrans %}

View File

@ -0,0 +1,11 @@
{% extends "emails/base-body-html.jinja" %}
{% block body %}
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
<h1>Github Project imported</h1>
<p>Hello {{ user }},</p>
<h3>Your Github project has been correctly imported.</h3>
<a class="button" href="{{ url }}" title="Go to the project {{ project }}">Go to {{ project }}</a>
<p><small>The Taiga Team</small></p>
{% endtrans %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
Hello {{ user }},
Your Github project has been correctly imported.
You can see the project {{ project }} here:
{{ url }}
---
The Taiga Team
{% endtrans %}

View File

@ -0,0 +1 @@
{% trans project=project.name|safe %}[{{ project }}] Your Github project has been imported{% endtrans %}

View File

@ -0,0 +1,12 @@
{% extends "emails/base-body-html.jinja" %}
{% block body %}
{% trans user=user.get_full_name(), error_message=error_message, support_email=sr("support.email") %}
<h1>{{ error_message }}</h1>
<p>Hello {{ user }},</p>
<p>Your project has not been importer correctly.</p>
<p>The Taiga system administrators have been informed.<br/> Please, try it again or contact with the support team at
<a href="mailto:{{ support_email }}" title="Support email" style="color: #699b05">{{ support_email }}</a></p>
<p><small>The Taiga Team</small></p>
{% endtrans %}
{% endblock %}

View File

@ -0,0 +1,14 @@
{% trans user=user.get_full_name(), error_message=error_message, support_email=sr("support.email") %}
Hello {{ user }},
{{ error_message }}
Your project has not been importer correctly.
The Taiga system administrators have been informed.
Please, try it again or contact with the support team at {{ support_email }}
---
The Taiga Team
{% endtrans %}

View File

@ -0,0 +1 @@
{% trans error_subject=error_subject|safe %}[Taiga] {{ error_subject }}{% endtrans %}

View File

@ -0,0 +1,11 @@
{% extends "emails/base-body-html.jinja" %}
{% block body %}
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
<h1>Jira Project imported</h1>
<p>Hello {{ user }},</p>
<h3>Your Jira project has been correctly imported.</h3>
<a class="button" href="{{ url }}" title="Go to the project {{ project }}">Go to {{ project }}</a>
<p><small>The Taiga Team</small></p>
{% endtrans %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
Hello {{ user }},
Your Jira project has been correctly imported.
You can see the project {{ project }} here:
{{ url }}
---
The Taiga Team
{% endtrans %}

View File

@ -0,0 +1 @@
{% trans project=project.name|safe %}[{{ project }}] Your Jira project has been imported{% endtrans %}

View File

@ -0,0 +1,11 @@
{% extends "emails/base-body-html.jinja" %}
{% block body %}
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
<h1>Trello Project imported</h1>
<p>Hello {{ user }},</p>
<h3>Your Trello project has been correctly imported.</h3>
<a class="button" href="{{ url }}" title="Go to the project {{ project }}">Go to {{ project }}</a>
<p><small>The Taiga Team</small></p>
{% endtrans %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% trans user=user.get_full_name(), url=resolve_front_url("project", project.slug), project=project.name %}
Hello {{ user }},
Your Trello project has been correctly imported.
You can see the project {{ project }} here:
{{ url }}
---
The Taiga Team
{% endtrans %}

View File

@ -0,0 +1 @@
{% trans project=project.name|safe %}[{{ project }}] Your Trello project has been imported{% endtrans %}

View File

@ -31,7 +31,7 @@ logger = logging.getLogger('taiga.importers.trello')
@app.task(bind=True)
def import_project(self, user_id, token, project_id, options):
user = User.object.get(id=user_id)
user = User.objects.get(id=user_id)
importer = TrelloImporter(user, token)
try:
project = importer.import_project(project_id, options)
@ -44,7 +44,7 @@ def import_project(self, user_id, token, project_id, options):
"project": project_id,
"exception": e
}
email = mail_builder.trello_import_error(admin, ctx)
email = mail_builder.importer_import_error(admin, ctx)
email.send()
logger.error('Error importing Trello project %s (by %s)', project_id, user, exc_info=sys.exc_info())
else: