1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """
20 Modul do wyswietlania danych.
21
22 Obiekt obsluguje strone ze szczegolami rekordu z bazy danych. Moga one
23 pochodzic zarowno z pojedynczej tabeli jak i jako wynik zapytania SQL.
24
25 Obiekt Generujacy
26 =================
27
28 L{ajango.generator.views.display}
29 """
30
31 from django.utils.datastructures import MultiValueDictKeyError
32 from django.core.management.base import CommandError
33 from ajango.site.sites import GetSite
34 from ajango.site.sites.list import Site as List
35 from ajango.database.columns.button import Column as Button
36
37 -class Site(List, GetSite):
38 """ Klasa do wyswietlania danych. """
40 self.column = []
41 List.__init__(self, ob)
43 """ Metoda inicjalizujaca. """
44 self.type = 'display'
45 self.column = []
47 """ Zwraca id rekordu ktory wyswietla. """
48 try:
49 identity = self.request.GET['id']
50 except MultiValueDictKeyError:
51 identity = -1
52 return identity
54 """ Buduje dane dla strony. """
55 self.data['tabledata'] = []
56 results = self.query.get_by_filter({'id' : self.get_id()})
57 if len(results) < 1:
58 self.data['result'] = False
59 else:
60 elem = results[0]
61 self.data['result'] = True
62 line = []
63 for col in self.column:
64 if isinstance(col, Button):
65 raise CommandError("Display view cannot have Button column")
66 else:
67 line.append(col.get_data({'result': elem}))
68 self.data['tabledata'] = line
69