summaryrefslogtreecommitdiffstats
path: root/app/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/views.py')
-rw-r--r--app/views.py35
1 files changed, 1 insertions, 34 deletions
diff --git a/app/views.py b/app/views.py
index 3cc8891..acaf3f1 100644
--- a/app/views.py
+++ b/app/views.py
@@ -2,42 +2,9 @@ from flask import jsonify, abort, make_response, request, url_for, redirect, ses
from requests_oauthlib import OAuth2Session
from datetime import datetime
from app import app, db, models
+from app.utils import authenticate, ticket_to_dict, make_public_ticket
import json
-def make_public_ticket(ticket):
- new_ticket = ticket.copy()
- new_ticket['uri'] = url_for('get_ticket', ticket_id=ticket['id'], _external=True)
- return new_ticket
-
-def ticket_to_dict(ticket):
- nt = {}
- nt['id'] = ticket.id
-
- nt['summary'] = ticket.summary
- nt['body'] = ticket.body
-
- nt['opened_at'] = ticket.opened_at.strftime('%Y-%m-%dT%H:%M:%S')
-
- if ticket.updated_at:
- nt['updated_at'] = ticket.updated_at.strftime('%Y-%m-%dT%H:%M:%S')
- else:
- nt['updated_at'] = None
-
- nt['status'] = ticket.status
-
- nt['reason'] = ticket.reason
-
- if ticket.opened_by:
- nt['opened_by'] = {
- 'id': ticket.opened_by.id,
- 'nickname': ticket.opened_by.nickname,
- 'email': ticket.opened_by.email,
- }
- else:
- nt['opened_by'] = {'id': None, 'nickname': None, 'email': None}
-
- return nt
-
@app.route('/authorized')
def authorized_callback():
github = OAuth2Session(app.config['GITHUB_CLIENT_ID'], state=session['oauth_state'])