Revision cc7c5902 ui/views.py

b/ui/views.py
1
# Create your views here.
1
from chameleon.zpt import 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' : 'ubuntu.png'},
16
                 {'id':2, 'name':'My name server', 'state':'3','public_ip':'147.102.1.64', 'thumb' : 'debian.png'},
17
                 {'id':3, 'name':'My file server', 'state':'3','public_ip':'147.102.1.65', 'thumb' : 'fedora.png'},
18
                 {'id':4, 'name':'My torrent server', 'state':'3','public_ip':'147.102.1.66', 'thumb' : 'gentoo.png'},
19
                 {'id':5, 'name':'My firewall', 'state':'3','public_ip':'147.102.1.67', 'thumb' : 'netbsd.png'},
20
                 {'id':6, 'name':'My windows workstation', 'state':'0','public_ip':'147.102.1.69', 'thumb' : 'windows.png'},
21
                ]
22
def template(name, context):
23
    template_path = os.path.join(os.path.dirname(__file__), "templates")  
24
    tl = loader.TemplateLoader(template_path)
25
    t = tl.load(name+'.pt')
26
    return HttpResponse(t.render(context=context))
27

  
28
def home(request):
29
    context = { 'project' : '+nefo' }
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 instances_list(request):
37
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
38
    return template('list', context)
39

  
40
def images(request): 
41
    context = {'images': DEFAULT_IMAGES}
42
    return template('images', context)
43

  
44
def disks(request):
45
    context = { 'project' : '+nefo' }
46
    return template('disks', context)
47

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

Also available in: Unified diff