Package ajango :: Package site :: Package sites :: Module raport
[hide private]
[frames] | no frames]

Source Code for Module ajango.site.sites.raport

 1  ########################################################################### 
 2  #                                                                         # 
 3  #  Copyright (C) 2016  Rafal Kobel <rafyco1@gmail.com>                    # 
 4  #                                                                         # 
 5  #  This program is free software: you can redistribute it and/or modify   # 
 6  #  it under the terms of the GNU General Public License as published by   # 
 7  #  the Free Software Foundation, either version 3 of the License, or      # 
 8  #  (at your option) any later version.                                    # 
 9  #                                                                         # 
10  #  This program is distributed in the hope that it will be useful,        # 
11  #  but WITHOUT ANY WARRANTY; without even the implied warranty of         # 
12  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           # 
13  #  GNU General Public License for more details.                           # 
14  #                                                                         # 
15  #  You should have received a copy of the GNU General Public License      # 
16  #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  # 
17  #                                                                         # 
18  ########################################################################### 
19  """ 
20  Modul wyswietlania raportu. 
21   
22  Obiekt obsluguje strone wyswietlajaca raport na podstawie wybranych danych. 
23   
24  Obiekt Generujacy 
25  ================= 
26   
27  L{ajango.generator.views.raport} 
28  """ 
29   
30  from django.core.management.base    import CommandError 
31  from ajango.site.sites              import GetSite 
32  from ajango.site.sites.list         import Site   as List 
33  from ajango.database.columns.button import Column as Button 
34   
35 -class Site(List, GetSite):
36 """ Klasa wyswietlania raportu. """
37 - def __init__(self, ob):
38 self.list_mode = False 39 List.__init__(self, ob) 40 self.set_layout("ajango_raport.html")
41 - def get_request(self):
42 """ Zwraca obiekt request. """ 43 return self.request
44 - def set_template(self, template, is_build=True):
45 """ Ustawienie pliku z szablonem dla raportu. """ 46 if is_build: 47 template = "ajango_raports/ajango_%s.html" % template 48 self.set_include(template)
49 - def set_list_mode(self, value):
50 """ Wlaczenie lub wylaczenie trybu listy. """ 51 self.list_mode = value
52 - def content(self):
53 """ Buduje dane dla strony. """ 54 self.data['tabledata'] = [] 55 elem_id = self.get_id() 56 if elem_id >= 0: 57 results = self.query.get_by_filter({'id' : elem_id}) 58 else: 59 results = self.query.get_all() 60 if len(results) < 1: 61 self.data['result'] = False 62 else: 63 data = [] 64 for elem in results: 65 line = [] 66 for col in self.column: 67 if isinstance(col, Button): 68 raise CommandError("Display view cannot " 69 "have Button column") 70 else: 71 line.append(col.get_data({'result' : elem})) 72 data.append(list(line)) 73 self.data['tabledata'] = data 74 self.data['list_mode'] = self.list_mode
75