root / ui / views.py @ 54479111
History | View | Annotate | Download (2.1 kB)
1 |
import os |
---|---|
2 |
from django.conf import settings |
3 |
from django.utils.translation import gettext_lazy as _ |
4 |
from django.template import Context, loader |
5 |
from django.http import HttpResponse |
6 |
from django.utils.translation import get_language |
7 |
from django.utils import simplejson as json |
8 |
import time |
9 |
|
10 |
TIMEOUT = settings.TIMEOUT |
11 |
CONSOLE_WIDTH = 800 #settings.CONSOLE_WIDTH |
12 |
CONSOLE_HEIGHT = 600 #settings.CONSOLE_HEIGHT |
13 |
|
14 |
def template(name, context): |
15 |
template_path = os.path.join(os.path.dirname(__file__), "templates/")
|
16 |
current_template = template_path + name + '.html'
|
17 |
t = loader.get_template(current_template) |
18 |
return HttpResponse(t.render(Context(context)))
|
19 |
|
20 |
|
21 |
def home(request): |
22 |
context = {'timeout': TIMEOUT,
|
23 |
'project': '+nefo', |
24 |
'request': request,
|
25 |
'current_lang': get_language() or 'en'} |
26 |
return template('home', context) |
27 |
|
28 |
|
29 |
def machines(request): |
30 |
context = {} |
31 |
return template('machines', context) |
32 |
|
33 |
def machine_console(request): |
34 |
host, port, password = ('','','') |
35 |
host = request.GET.get('host','') |
36 |
port = request.GET.get('port','') |
37 |
password = request.GET.get('password','') |
38 |
context = {'host': host, 'port': port, 'password': password, |
39 |
'console_height': CONSOLE_HEIGHT, 'console_width': CONSOLE_WIDTH} |
40 |
return template('machine_console', context) |
41 |
|
42 |
def machines_standard(request): |
43 |
context = {} |
44 |
return template('standard', context) |
45 |
|
46 |
|
47 |
def machines_list(request): |
48 |
context = {} |
49 |
return template('list', context) |
50 |
|
51 |
|
52 |
def images(request): |
53 |
context = {} |
54 |
return template('images', context) |
55 |
|
56 |
|
57 |
def disks(request): |
58 |
context = {} |
59 |
return template('disks', context) |
60 |
|
61 |
|
62 |
def networks(request): |
63 |
context = {} |
64 |
return template('networks', context) |
65 |
|
66 |
|
67 |
def files(request): |
68 |
context = {} |
69 |
return template('files', context) |
70 |
|
71 |
|
72 |
def desktops(request): |
73 |
context = {} |
74 |
return template('desktops', context) |
75 |
|
76 |
|
77 |
def apps(request): |
78 |
context = {} |
79 |
return template('apps', context) |
80 |
|
81 |
def current_datetime(request): |
82 |
now = time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime())
|
83 |
html = "<html><body>%s</body></html>" % now
|
84 |
return HttpResponse(html)
|