Statistics
| Branch: | Tag: | Revision:

root / ui / views.py @ b80d3c62

History | View | Annotate | Download (3 kB)

1
from django.template import Context, loader
2
from django.http import HttpResponse
3
import os
4

    
5
DEFAULT_IMAGES = [
6
              {'id': 'ubuntu-10.10-x86_64-server', 'type':'standard', 'title': 'Ubuntu 10.10 server 64bit', 'description': 'Apache, MySQL, php5 preinstalled', 'size': '834', 'logo':'static/ubuntu.png'}, 
7
              {'id': 'fedora-14-desktop', 'type':'standard', 'title': 'Fedora 14 desktop 32bit', 'description': 'Apache, MySQL, php5 preinstalled', 'size': '912', 'logo':'static/fedora.png'}, 
8
              {'id': 'windows7-pro', 'type':'standard', 'title': 'Windows 7 professional', 'description': 'MS Office 7 preinstalled', 'size': '8142', 'logo':'static/windows.png'}, 
9
              {'id': 'windows-xp', 'type':'standard', 'title': 'Windows XP', 'description': 'MS Office XP preinstalled', 'size': '6192', 'logo':'static/windows.png'},
10
              {'id': 'netbsd-server', 'type':'custom', 'title': 'NetBSD server', 'description': 'my secure torrent server', 'size': '898', 'logo':'static/netbsd.png'}, 
11
              {'id': 'gentoo-playroom', 'type':'custom', 'title': 'Centoo', 'description': 'online pinaball olympiad server', 'size': '912', 'logo':'static/gentoo.png'},  
12
             ]
13

    
14
DEFAULT_NODES = [
15
                 {'id':1, 'name':'My mail server', 'state':'3','public_ip':'147.102.1.62', 'thumb' : 'static/ubuntu.png'},
16
                 {'id':2, 'name':'My name server', 'state':'3','public_ip':'147.102.1.64', 'thumb' : 'static/debian.png'},
17
                 {'id':3, 'name':'My file server', 'state':'3','public_ip':'147.102.1.65', 'thumb' : 'static/fedora.png'},
18
                 {'id':4, 'name':'My torrent server', 'state':'3','public_ip':'147.102.1.66', 'thumb' : 'static/gentoo.png'},
19
                 {'id':5, 'name':'My firewall', 'state':'3','public_ip':'147.102.1.67', 'thumb' : 'static/netbsd.png'},
20
                 {'id':6, 'name':'My windows workstation', 'state':'0','public_ip':'147.102.1.69', 'thumb' : 'static/windows.png'},
21
                ]
22
def template(name, context):
23
    template_path = os.path.join(os.path.dirname(__file__), "templates/")  
24
    current_template = template_path + name + '.html'
25
    t = loader.get_template(current_template)
26
    return HttpResponse(t.render(Context(context)))
27

    
28
def home(request):
29
    context = { 'project' : '+nefo', 'request': request }
30
    return template('home', context)
31

    
32
def instances(request):
33
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
34
    return template('instances', context)
35

    
36
def alt_instances(request):
37
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
38
    return template('alt_instances', context)
39
   
40
def instances_list(request):
41
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
42
    return template('list', context)
43

    
44
def images(request): 
45
    context = {'images': DEFAULT_IMAGES}
46
    return template('images', context)
47

    
48
def disks(request):
49
    context = { 'project' : '+nefo' }
50
    return template('disks', context)
51

    
52
def networks(request):
53
    context = { 'project' : '+nefo' }
54
    return template('networks', context)