示例#1
0
文件: views.py 项目: ucamhal/Shahnama
 def summary(self, quick=False):
     if self.summaryMap is None:
         try:
             self.loadJson()
             if self.json is not None:
                 # references
                 refmap = {
                     'GeneralRef1': 'General',
                     'GeneralRef2': 'General',
                     'GeneralRef3': 'General',
                     'IllustrationReference': 'Illustrations',
                     'AttributionEstimate': 'Folio count',
                     'AttributionOrigin': 'Origin',
                     'AttributionDate': 'Date',
                 }
                 gallery = GalleryView()
                 locationView = LocationView(self.request, self.model.location)
                 loc = { 'Country': '', 'country': '' }
                 if not quick:
                     if 'Colophon' in self.json  and self.json['Colophon'] is not None:
                         gallery.galleryData.append(GalleryView.entry(self._image_url(self.request, self.json, 'Colophon'), '#', 'Colophon', self.json['ColophonNumber'], '', ''))
                     if 'SamplePage' in self.json and self.json['SamplePage'] is not None:
                         gallery.galleryData.append(GalleryView.entry(self._image_url(self.request, self.json, 'SamplePage'), '#', 'Sample page from this manuscript', '', '', ''))
                     gallery.extend([ IllustrationView(self.request, model=x) for x in self.model.illustration_set.all()])
                     loc = locationView.summary(True)
                 extra = {
                     'gallery': gallery.emit(),
                     'size': self._size_expr(self.getSafeProperty('PageWidth'), self.getSafeProperty('PageLength'), self.getSafeProperty('TextWidth'), self.getSafeProperty('TextLength')),
                     'text': text_tmpl.apply(self.request, self.json),
                     'pages': pages_tmpl.apply(self.request, self.json),
                     'state': state_tmpl.apply(self.request, self.json),
                     'origin': origin_tmpl.apply(self.frequest, self.json),
                     'date': "%s (%s)" % (Hijri.date(self.getSafeProperty('HijriDate')), Gregorian.date(self.getSafeProperty('GregorianDate'))),
                     'references': ReferenceView.refs_tmpl(self.request, self.json, refmap),
                     'notes': wash_notes(self.getSafeProperty('NotesVisible')),
                     'status': JsonModel.safe_to_json(Authority.objects.get(name='record-status', id=self.getSafeProperty('CompletionStatus'))),
                     'up_date': format_date(self.getSafeProperty('DateUpdated')),
                     'canon-image': self._canon_image(self.request, self.json),
                     'location_text': locationView.text(),
                     'location_url': '%s/location/%s' % (SERVER_ROOT_URL, self.getSafeProperty('LocationSerial')),
                     'country': self.getSafeProperty('country', map=loc),
                     'country_url': '%s/country/%s' % (SERVER_ROOT_URL, self.getSafeProperty('country', map=loc)),
                     'prev-url': "%s/manuscript/%s" % (SERVER_ROOT_URL, self.json['chain-prev-date']) if 'chain-prev-date' in self.json else '',
                     'next-url': "%s/manuscript/%s" % (SERVER_ROOT_URL, self.json['chain-next-date']) if 'chain-next-date' in self.json else '',
                 }
                 self.summaryMap = dict(self.json.items() + extra.items())
             else:
                 self.summaryMap = {}
         except:
             self.summaryMap = {}
     return self.summaryMap
示例#2
0
文件: views.py 项目: ucamhal/Shahnama
 def summary(self,quick = False):
     if self.summaryMap is None:
         allChapters = Chapter.objects.all()
         chapters = []
         gallery = GalleryView()
         for chapter in allChapters:
             
             chapterJson = JsonModel.safe_to_json(chapter)
             code = chapterJson['ChapterCode'].strip()
             chapters.append({
                 'name': chapterJson['ChapterName'],
                 'code': code,
                 'url': "%s/chapter/%s" % (SERVER_ROOT_URL, chapter.id)
             })
             if self.id is not None and str(self.id) == str(chapter.id):
                 gallery.galleryData = [ SceneView(self.request, model = x ).gallery() for x in chapter.scene_set.all()]
             
         extra = {
                  # this sort should be done in the query above
             'chapters': sorted(chapters,key = lambda x: self._order(x['code'])),
             'gallery': gallery.emit(),
         }
         self.summaryMap = dict(extra.items())
     return self.summaryMap
示例#3
0
 def summary(self,quick = False):
     if self.summaryMap is None:
         allChapters = Chapter.objects.all()
         chapters = []
         gallery = GalleryView()
         for chapter in allChapters:
             
             chapterJson = JsonModel.safe_to_json(chapter)
             code = chapterJson['ChapterCode'].strip()
             chapters.append({
                 'name': chapterJson['ChapterName'],
                 'code': code,
                 'url': "%s/chapter/%s" % (SERVER_ROOT_URL, chapter.id)
             })
             if self.id is not None and str(self.id) == str(chapter.id):
                 gallery.galleryData = [ SceneView(self.request, model = x ).gallery() for x in chapter.scene_set.all()]
             
         extra = {
                  # this sort should be done in the query above
             'chapters': sorted(chapters,key = lambda x: self._order(x['code'])),
             'gallery': gallery.emit(),
         }
         self.summaryMap = dict(extra.items())
     return self.summaryMap
示例#4
0
文件: views.py 项目: ucamhal/Shahnama
 def loadJson(self):
     if self.json is None:
         if self.model is None:
             self.loadModel()
         self.json = JsonModel.safe_to_json(self.model)
示例#5
0
 def loadJson(self):
     if self.json is None:
         if self.model is None:
             self.loadModel()
         self.json = JsonModel.safe_to_json(self.model)