2016-03-08 08:18:41 +00:00
|
|
|
from flask import (
|
|
|
|
|
render_template,
|
|
|
|
|
session,
|
|
|
|
|
flash
|
|
|
|
|
)
|
|
|
|
|
|
2016-01-06 16:40:38 +00:00
|
|
|
from flask_login import login_required
|
2015-12-18 10:26:56 +00:00
|
|
|
from app.main import main
|
2016-01-15 16:10:24 +00:00
|
|
|
from app.main.dao.services_dao import get_service_by_id
|
2016-02-02 09:38:58 +00:00
|
|
|
from app.main.dao import templates_dao
|
2016-02-03 14:43:16 +00:00
|
|
|
from app import job_api_client
|
2015-12-18 10:26:56 +00:00
|
|
|
|
|
|
|
|
|
2016-02-02 14:24:08 +00:00
|
|
|
@main.route("/services/<service_id>/dashboard")
|
2016-01-06 16:40:38 +00:00
|
|
|
@login_required
|
2016-01-15 17:46:09 +00:00
|
|
|
def service_dashboard(service_id):
|
2016-03-10 11:53:29 +00:00
|
|
|
templates = templates_dao.get_service_templates(service_id)['data']
|
|
|
|
|
jobs = job_api_client.get_job(service_id)['data']
|
|
|
|
|
|
|
|
|
|
service = get_service_by_id(service_id)
|
|
|
|
|
session['service_name'] = service['data']['name']
|
|
|
|
|
session['service_id'] = service['data']['id']
|
|
|
|
|
|
|
|
|
|
if session.get('invited_user'):
|
|
|
|
|
session.pop('invited_user', None)
|
|
|
|
|
service_name = service['data']['name']
|
2016-03-11 10:16:06 +00:00
|
|
|
message = 'You have successfully accepted your invitation and been added to {}'.format(service_name)
|
2016-03-10 11:53:29 +00:00
|
|
|
flash(message, 'default_with_tick')
|
2016-03-08 08:18:41 +00:00
|
|
|
|
2015-12-18 10:26:56 +00:00
|
|
|
return render_template(
|
2016-01-15 17:46:09 +00:00
|
|
|
'views/service_dashboard.html',
|
2016-02-04 17:13:57 +00:00
|
|
|
jobs=list(reversed(jobs))[:5],
|
|
|
|
|
more_jobs_to_show=(len(jobs) > 5),
|
2016-02-04 12:20:24 +00:00
|
|
|
free_text_messages_remaining='250,000',
|
2016-01-13 12:10:29 +00:00
|
|
|
spent_this_month='0.00',
|
2016-02-02 13:38:39 +00:00
|
|
|
template_count=len(templates),
|
2016-02-02 14:24:08 +00:00
|
|
|
service_id=str(service_id))
|