root / ui / views.py @ ec06b07c
History | View | Annotate | Download (2.8 kB)
1 |
import os |
---|---|
2 |
from django.utils.translation import gettext_lazy as _ |
3 |
from django.template import Context, loader |
4 |
from django.http import HttpResponse |
5 |
from django.utils.translation import get_language |
6 |
|
7 |
DEFAULT_IMAGES = [ |
8 |
{'id': 'ubuntu-10.10-x86_64-server', 'type':'standard', 'title': 'Ubuntu 10.10 server 64bit', 'description': _('Apache, MySQL, php5 preinstalled'), 'size': '834', 'logo':'ubuntu.png'}, |
9 |
{'id': 'fedora-14-desktop', 'type':'standard', 'title': 'Fedora 14 desktop 32bit', 'description': 'Apache, MySQL, php5 preinstalled', 'size': '912', 'logo':'fedora.png'}, |
10 |
{'id': 'windows7-pro', 'type':'standard', 'title': 'Windows 7 professional', 'description': 'MS Office 7 preinstalled', 'size': '8142', 'logo':'windows.png'}, |
11 |
{'id': 'windows-xp', 'type':'standard', 'title': 'Windows XP', 'description': 'MS Office XP preinstalled', 'size': '6192', 'logo':'windows.png'}, |
12 |
{'id': 'netbsd-server', 'type':'custom', 'title': 'NetBSD server', 'description': 'my secure torrent server', 'size': '898', 'logo':'netbsd.png'}, |
13 |
{'id': 'gentoo-playroom', 'type':'custom', 'title': 'Centoo', 'description': 'online pinaball olympiad server', 'size': '912', 'logo':'gentoo.png'}, |
14 |
] |
15 |
|
16 |
DEFAULT_NODES = [ |
17 |
{'id':1, 'name':'My mail server', 'state':'3','public_ip':'147.102.1.62', 'thumb' : 'ubuntu.png'}, |
18 |
{'id':2, 'name':'My name server', 'state':'3','public_ip':'147.102.1.64', 'thumb' : 'debian.png'}, |
19 |
{'id':3, 'name':'My file server', 'state':'3','public_ip':'147.102.1.65', 'thumb' : 'ubuntu.png'}, |
20 |
{'id':4, 'name':'My torrent server', 'state':'3','public_ip':'147.102.1.66', 'thumb' : 'gentoo.png'}, |
21 |
{'id':5, 'name':'My firewall', 'state':'3','public_ip':'147.102.1.67', 'thumb' : 'netbsd.png'}, |
22 |
{'id':6, 'name':'My windows workstation', 'state':'0','public_ip':'147.102.1.69', 'thumb' : 'windows-off.png'}, |
23 |
] |
24 |
|
25 |
def template(name, context): |
26 |
template_path = os.path.join(os.path.dirname(__file__), "templates/")
|
27 |
current_template = template_path + name + '.html'
|
28 |
t = loader.get_template(current_template) |
29 |
return HttpResponse(t.render(Context(context)))
|
30 |
|
31 |
def home(request): |
32 |
context = { 'project' : '+nefo', 'request': request, 'current_lang' : get_language() or 'en' } |
33 |
return template('home', context) |
34 |
|
35 |
def instances(request): |
36 |
context = {} |
37 |
return template('instances', context) |
38 |
|
39 |
def instances_list(request): |
40 |
context = {} |
41 |
return template('list', context) |
42 |
|
43 |
def images(request): |
44 |
context = {} |
45 |
return template('images', context) |
46 |
|
47 |
def disks(request): |
48 |
context = {} |
49 |
return template('disks', context) |
50 |
|
51 |
def networks(request): |
52 |
context = {} |
53 |
return template('networks', context) |