Revision b303ba05 ui/views.py

b/ui/views.py
1
from chameleon.zpt import loader
1
from django.template import Context, loader
2 2
from django.http import HttpResponse
3 3
import os
4 4

  
5 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'},  
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 12
             ]
13 13

  
14 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'},
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 21
                ]
22 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))
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 27

  
28 28
def home(request):
29 29
    context = { 'project' : '+nefo' }

Also available in: Unified diff