root / ui / views.py @ f533f224
History | View | Annotate | Download (2.3 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 |
from django.shortcuts import render_to_response |
9 |
|
10 |
TIMEOUT = settings.TIMEOUT |
11 |
IMAGE_ICONS = settings.IMAGE_ICONS |
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 |
def home(request): |
20 |
context = {'timeout': TIMEOUT,
|
21 |
'project': '+nefo', |
22 |
'request': request,
|
23 |
'current_lang': get_language() or 'en', |
24 |
'image_icons': IMAGE_ICONS,}
|
25 |
return template('home', context) |
26 |
|
27 |
def machines(request): |
28 |
context = {'default_keywords': settings.DEFAULT_KEYWORDS}
|
29 |
return template('machines', context) |
30 |
|
31 |
def machines_icon(request): |
32 |
context = {'default_keywords': settings.DEFAULT_KEYWORDS}
|
33 |
return template('machines_icon', context) |
34 |
|
35 |
def machines_list(request): |
36 |
context = {'default_keywords': settings.DEFAULT_KEYWORDS}
|
37 |
return template('machines_list', context) |
38 |
|
39 |
def machines_single(request): |
40 |
context = {'default_keywords': settings.DEFAULT_KEYWORDS}
|
41 |
return template('machines_single', context) |
42 |
|
43 |
def machines_console(request): |
44 |
host, port, password = ('','','') |
45 |
host = request.GET.get('host','') |
46 |
port = request.GET.get('port','') |
47 |
password = request.GET.get('password','') |
48 |
machine = request.GET.get('machine','') |
49 |
host_ip = request.GET.get('host_ip','') |
50 |
context = {'host': host, 'port': port, 'password': password, 'machine': machine, 'host_ip': host_ip} |
51 |
return template('machines_console', context) |
52 |
|
53 |
def images(request): |
54 |
context = {} |
55 |
return template('images', context) |
56 |
|
57 |
def disks(request): |
58 |
context = {} |
59 |
return template('disks', context) |
60 |
|
61 |
def networks(request): |
62 |
context = {} |
63 |
return template('networks', context) |
64 |
|
65 |
def files(request): |
66 |
context = {} |
67 |
return template('files', context) |
68 |
|
69 |
def desktops(request): |
70 |
context = {} |
71 |
return template('desktops', context) |
72 |
|
73 |
def apps(request): |
74 |
context = {} |
75 |
return template('apps', context) |