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
/
Copy pathviews.py
77 lines (63 loc) · 2.58 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
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, 'sequencing_layout/index.html', context)
def generate_files(request):
if request.method == "POST":
data = request.POST
input_str = data['manualFields']
username = data['userName']
plate_id = data['plateID']
email_address = data['emailAddress']
machine = data['sequencingMachine']
# Run actual calculatiuon
from . import sequencing_generate_files
output_t = sequencing_generate_files.run(input_str, username, plate_id, email_address, machine)
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/sequencing_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/sequencing_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/sequencing_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__)