root / ui / views.py @ 69a37abb
History | View | Annotate | Download (1.9 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 |
|
9 |
TIMEOUT = settings.TIMEOUT |
10 |
CONSOLE_WIDTH = 800 #settings.CONSOLE_WIDTH |
11 |
CONSOLE_HEIGHT = 600 #settings.CONSOLE_HEIGHT |
12 |
|
13 |
def template(name, context): |
14 |
template_path = os.path.join(os.path.dirname(__file__), "templates/")
|
15 |
current_template = template_path + name + '.html'
|
16 |
t = loader.get_template(current_template) |
17 |
return HttpResponse(t.render(Context(context)))
|
18 |
|
19 |
|
20 |
def home(request): |
21 |
context = {'timeout': TIMEOUT,
|
22 |
'project': '+nefo', |
23 |
'request': request,
|
24 |
'current_lang': get_language() or 'en'} |
25 |
return template('home', context) |
26 |
|
27 |
|
28 |
def machines(request): |
29 |
context = {} |
30 |
return template('machines', context) |
31 |
|
32 |
def machine_console(request): |
33 |
host, port, password = ('','','') |
34 |
host = request.GET.get('host','') |
35 |
port = request.GET.get('port','') |
36 |
password = request.GET.get('password','') |
37 |
context = {'host': host, 'port': port, 'password': password, |
38 |
'console_height': CONSOLE_HEIGHT, 'console_width': CONSOLE_WIDTH} |
39 |
return template('machine_console', context) |
40 |
|
41 |
def machines_standard(request): |
42 |
context = {} |
43 |
return template('standard', context) |
44 |
|
45 |
|
46 |
def machines_list(request): |
47 |
context = {} |
48 |
return template('list', context) |
49 |
|
50 |
|
51 |
def images(request): |
52 |
context = {} |
53 |
return template('images', context) |
54 |
|
55 |
|
56 |
def disks(request): |
57 |
context = {} |
58 |
return template('disks', context) |
59 |
|
60 |
|
61 |
def networks(request): |
62 |
context = {} |
63 |
return template('networks', context) |
64 |
|
65 |
|
66 |
def files(request): |
67 |
context = {} |
68 |
return template('files', context) |
69 |
|
70 |
|
71 |
def desktops(request): |
72 |
context = {} |
73 |
return template('desktops', context) |
74 |
|
75 |
|
76 |
def apps(request): |
77 |
context = {} |
78 |
return template('apps', context) |