This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
87 lines (68 loc) · 2.73 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from django.shortcuts import render
from django.http import HttpResponse
from django.template import Template, RequestContext
import os, sys
from django.contrib.auth.decorators import login_required
UTIL_PATH = "/alldata/bblab_site/depend/util_scripts"
sys.path.append(UTIL_PATH)
import django_utils
def index(request):
context={}
if request.user.is_authenticated:
context["user_authenticated"]=True
context["username"]=request.user.username
return render(request, 'guava_layout/index.html', context)
def index_column(request):
context={}
if request.user.is_authenticated:
context["user_authenticated"]=True
context["username"]=request.user.username
return render(request, 'guava_layout/indexAddOnColumn.html', context)
def generate_files(request):
if request.method == "POST":
data = request.POST
input_str = data['manualFields']
session_id = data['sessionID']
row_column = data['rowColumn']
email_address = data['email']
# Run actual calculatiuon
from . import guava_generate_files
output_t = guava_generate_files.run(input_str, session_id, row_column, email_address)
template = Template(output_t)
context = RequestContext(request)
return HttpResponse(template.render(context))
else:
return HttpResponse("Please use the form to submit data.")
##### Directory Display Functions #####
@login_required
def output(request, filename=None):
if filename == None:
template = Template(django_utils.dir_index_str( "output/", request, "/django/tools/guava_layout/", __file__ ))
context = RequestContext(request)
context["user_authenticated"]=True
context["username"]=request.user.username
return HttpResponse(template.render(context))
else:
return django_utils.read_file(filename, "output/", __file__)
@login_required
def archive(request, filename=None):
if filename == None:
template = Template(django_utils.dir_index_str( "output/archived_layouts/", request,
"/django/tools/guava_layout/output/", __file__ ))
context = RequestContext(request)
context["user_authenticated"]=True
context["username"]=request.user.username
return HttpResponse(template.render(context))
else:
return django_utils.read_file(filename, "output/archived_layouts/", __file__)
@login_required
def old_archive(request, filename=None):
if filename == None:
template = Template(django_utils.dir_index_str( "output/archived_layouts/old_archived_layouts/",
request, "/django/tools/guava_layout/output/archived_layouts/", __file__ ))
context = RequestContext(request)
context["user_authenticated"]=True
context["username"]=request.user.username
return HttpResponse(template.render(context))
else:
return django_utils.read_file(filename, "output/archived_layouts/old_archived_layouts/", __file__)