1 # -*- coding: utf-8 -*- |
|
2 |
|
3 import os |
1 import os |
4 |
2 |
5 from django.contrib.auth import login |
3 from django.contrib.auth import login |
6 from django.contrib.auth.decorators import login_required |
4 from django.contrib.auth.decorators import login_required |
7 from django.contrib.auth.forms import AuthenticationForm |
5 from django.contrib.auth.forms import AuthenticationForm |
8 from django.contrib.auth.models import User |
6 from django.contrib.auth.models import User |
9 from django.core.urlresolvers import reverse |
7 from django.core.urlresolvers import reverse |
10 from django.shortcuts import render_to_response |
8 from django.shortcuts import render_to_response |
11 from django.template import RequestContext |
9 from django.template import RequestContext |
12 |
10 |
|
11 from project.scipycon.proceedings.booklet import mk_scipy_paper |
|
12 from project.scipycon.proceedings.forms import ProceedingsForm |
13 from project.scipycon.proceedings.models import Paper |
13 from project.scipycon.proceedings.models import Paper |
14 from project.scipycon.user.forms import RegisterForm |
14 from project.scipycon.user.forms import RegisterForm |
15 from project.scipycon.user.models import UserProfile |
15 from project.scipycon.user.models import UserProfile |
16 from project.scipycon.utils import set_message_cookie |
16 from project.scipycon.utils import set_message_cookie |
17 from project.scipycon.proceedings.booklet import mk_scipy_paper |
|
18 from project.scipycon.proceedings.forms import ProceedingsForm |
|
19 |
17 |
20 |
18 |
21 def handleUploadedFile(proceedings_form_data, rst_file): |
19 def handleUploadedFile(proceedings_form_data, rst_file): |
22 """Handles the uploaded file content and process the form |
20 """Handles the uploaded file content and process the form |
23 """ |
21 """ |
35 |
33 |
36 return title, abstract, body, authors |
34 return title, abstract, body, authors |
37 |
35 |
38 |
36 |
39 @login_required |
37 @login_required |
40 def submit(request, id=None, template='proceedings/submit.html'): |
38 def submit(request, scope, id=None, template='proceedings/submit.html'): |
41 """View to submit the proceedings paper. |
39 """View to submit the proceedings paper. |
42 """ |
40 """ |
43 |
41 |
44 user = request.user |
42 user = request.user |
45 if user.is_authenticated(): |
43 if user.is_authenticated(): |
58 login_form = AuthenticationForm(data=request.POST) |
56 login_form = AuthenticationForm(data=request.POST) |
59 if login_form.is_valid(): |
57 if login_form.is_valid(): |
60 |
58 |
61 login(request, login_form.get_user()) |
59 login(request, login_form.get_user()) |
62 |
60 |
63 redirect_to = reverse('scipycon_submit_proceedings') |
61 redirect_to = reverse('scipycon_submit_proceedings', |
|
62 kwargs={'scope': scope}) |
64 return set_message_cookie(redirect_to, |
63 return set_message_cookie(redirect_to, |
65 msg = u'You have been logged in.') |
64 msg = u'You have been logged in.') |
66 |
65 |
67 if request.POST.get('action', None) == 'register': |
66 if request.POST.get('action', None) == 'register': |
68 # add the new user |
67 # add the new user |
85 abstract=abstract, body=body, |
84 abstract=abstract, body=body, |
86 authors=authors) |
85 authors=authors) |
87 |
86 |
88 # Successfully saved. So get back to the edit page. |
87 # Successfully saved. So get back to the edit page. |
89 redirect_to = reverse('scipycon_submit_proceedings', |
88 redirect_to = reverse('scipycon_submit_proceedings', |
90 args=[paper.id]) |
89 args=[paper.id], kwargs={'scope': scope}) |
91 return set_message_cookie( |
90 return set_message_cookie( |
92 redirect_to, msg = u'Thanks, your paper has been submitted.') |
91 redirect_to, msg = u'Thanks, your paper has been submitted.') |
93 else: |
92 else: |
94 # This is impossible. Something was wrong so return back |
93 # This is impossible. Something was wrong so return back |
95 # to submit page |
94 # to submit page |
96 redirect_to = reverse('scipycon_submit_proceedings') |
95 redirect_to = reverse('scipycon_submit_proceedings', |
|
96 kwargs={'scope': scope}) |
97 return set_message_cookie( |
97 return set_message_cookie( |
98 redirect_to, msg = u'Something is wrong here.') |
98 redirect_to, msg = u'Something is wrong here.') |
99 else: |
99 else: |
100 if id: |
100 if id: |
101 # If id exists initialize the form with old values |
101 # If id exists initialize the form with old values |
196 outfilename = '/media/python/workspace/scipycon/project/scipycon/proceedings/booklet/output/paper.pdf' |
196 outfilename = '/media/python/workspace/scipycon/project/scipycon/proceedings/booklet/output/paper.pdf' |
197 attach_dir = os.path.dirname('/media/python/workspace/scipycon/project/scipycon/proceedings/booklet/output/') |
197 attach_dir = os.path.dirname('/media/python/workspace/scipycon/project/scipycon/proceedings/booklet/output/') |
198 mk_scipy_paper.mk_abstract_preview(abstract, outfilename, attach_dir) |
198 mk_scipy_paper.mk_abstract_preview(abstract, outfilename, attach_dir) |
199 |
199 |
200 from django.http import HttpResponse |
200 from django.http import HttpResponse |
201 return HttpResponse('Machi') |
201 |
202 |
202 # TODO: Return something in the repo |
203 |
203 return HttpResponse('') |