Statistics
| Branch: | Tag: | Revision:

root / ui / views.py @ edda4d30

History | View | Annotate | Download (3 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

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

    
15
DEFAULT_NODES = [
16
                 {'id':1, 'name':'My mail server', 'state':'3','public_ip':'147.102.1.62', 'thumb' : 'ubuntu.png'},
17
                 {'id':2, 'name':'My name server', 'state':'3','public_ip':'147.102.1.64', 'thumb' : 'debian.png'},
18
                 {'id':3, 'name':'My file server', 'state':'3','public_ip':'147.102.1.65', 'thumb' : 'ubuntu.png'},
19
                 {'id':4, 'name':'My torrent server', 'state':'3','public_ip':'147.102.1.66', 'thumb' : 'gentoo.png'},
20
                 {'id':5, 'name':'My firewall', 'state':'3','public_ip':'147.102.1.67', 'thumb' : 'netbsd.png'},
21
                 {'id':6, 'name':'My windows workstation', 'state':'0','public_ip':'147.102.1.69', 'thumb' : 'windows-off.png'},
22
                ]
23

    
24
def template(name, context):
25
    template_path = os.path.join(os.path.dirname(__file__), "templates/")  
26
    current_template = template_path + name + '.html'
27
    t = loader.get_template(current_template)
28
    return HttpResponse(t.render(Context(context)))
29

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

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

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

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

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

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