Пример #1
0
 def to_dict(self):
     attr_dict = BaseModelObject.to_dict(self)
     attr_dict.update({'base_url': '{}/talks/{}'.format(config.AWS_IMAGES_BASE, self.uuid),
                       'formatted_date': format_date(self.date, format='%B %d, %Y'),
                       'next': Talk.next(self, attrs=['uuid'], sort_by='date', published=True, desc=False),
                       'prev': Talk.prev(self, attrs=['uuid'], sort_by='date', published=True, desc=False)})
     return attr_dict
Пример #2
0
 def to_dict(self, admin=False):
     base_url = '{}/galleries/{}'.format(config.AWS_IMAGES_BASE, self.uuid)
     gallery_categories = GalleryCategory.get_list(gallery_uuid=self.uuid, to_json=True)
     attr_dict = BaseModelObject.to_dict(self)
     attr_dict.update({'cover_photo_url': '{}/{}'.format(base_url, self.cover_photo),
                       'base_url': base_url,
                       'url_title': self.latest_url_title(),
                       'description': self.description(),
                       'created_ago': relative_time(self.created_at),
                       'published_at_raw': format_date(self.published_at, format='%Y-%m-%dT%H:%M:%S') if self.published_at else '',
                       'published_ago': relative_time(self.published_at) if self.published_at else '',
                       'gallery_categories': gallery_categories,
                       'items': GalleryItem.get_items(gallery_uuid=self.uuid, sort_by='position', desc=False, to_json=True, admin=admin),
                       'prev': Gallery.prev(self, attrs=['uuid', 'url_title'], sort_by='published_at', published=True, desc=False),
                       'next': Gallery.next(self, attrs=['uuid', 'url_title'], sort_by='published_at', published=True, desc=False)})
     return attr_dict
Пример #3
0
 def to_dict(self, admin=False):
     attr_dict = BaseModelObject.to_dict(self)
     base_url = '{}/galleries/{}'.format(config.AWS_IMAGES_BASE, self.uuid)
     gallery_categories = GalleryCategory.get_list(gallery_uuid=self.uuid, to_json=True)
     gallery_dict = {'cover_photo_url': '{}/{}'.format(base_url, self.cover_photo),
                     'base_url': base_url,
                     'url_title': self.latest_url_title(),
                     'description': self.description(),
                     'created_ago': relative_time(self.created_at),
                     'published_at_raw': format_date(self.published_at, format='%Y-%m-%dT%H:%M:%S'),
                     'published_ago': relative_time(self.published_at) if self.published_at else '',
                     'gallery_categories': gallery_categories,
                     'items': [item.to_dict() for item in self.items(admin=admin)],
                     'prev': Gallery.prev(self, attrs=['uuid', 'url_title'], sort_by='published_at',
                                          published=True, desc=False),
                     'next': Gallery.next(self, attrs=['uuid', 'url_title'], sort_by='published_at',
                                          published=True, desc=False)}
     attr_dict.update(gallery_dict)
     return attr_dict
Пример #4
0
 def to_dict(self, admin=False):
     attr_dict = BaseModelObject.to_dict(self)
     attr_dict.update({'author_email': self.author_name(),
                       'created_ago': relative_time(self.created_at)})
     return attr_dict
Пример #5
0
 def to_dict(self, admin=False):
     attr_dict = BaseModelObject.to_dict(self)
     if admin:
         attr_dict['comments'] = GalleryItemComment.get_list(to_json=True, gallery_item_uuid=self.uuid)
     return attr_dict
Пример #6
0
 def to_dict(self):
     attr_dict = BaseModelObject.to_dict(self)
     category = Category.get(uuid=self.category_uuid)
     attr_dict.update({'name': category.name})
     return attr_dict
Пример #7
0
 def to_dict(self):
     attr_dict = BaseModelObject.to_dict(self)
     subscription_categories = SubscriptionCategory.get_list(subscription_uuid=self.uuid, to_json=True)
     attr_dict.update({'categories': subscription_categories})
     return attr_dict
Пример #8
0
 def to_dict(self):
     attr_dict = BaseModelObject.to_dict(self)
     subscription_categories = SubscriptionCategory.get_list(subscription_uuid=self.uuid, to_json=True)
     attr_dict.update({'categories': subscription_categories})
     return attr_dict