def get(self, org): '''List organization discussions''' reuses = Reuse.objects(organization=org).only('id') datasets = Dataset.objects(organization=org).only('id') subjects = list(reuses) + list(datasets) qs = Discussion.objects(subject__in=subjects).order_by('-created') return list(qs)
def get(self, org): '''List organization discussions''' reuses = Reuse.objects(organization=org).only('id') datasets = Dataset.objects(organization=org).only('id') subjects = list(reuses) + list(datasets) qs = Discussion.objects(subject__in=subjects).order_by('-created') return list(qs)
def get(self, org): """List organization discussions""" reuses_ids = [r.id for r in Reuse.objects(organization=org).only("id")] datasets_ids = [d.id for d in Dataset.objects(organization=org).only("id")] ids = reuses_ids + datasets_ids qs = Discussion.objects(subject__in=ids).order_by("-created") return list(qs)
def get(self, org): '''List organization discussions''' reuses_ids = [r.id for r in Reuse.objects(organization=org).only('id')] datasets_ids = [d.id for d in Dataset.objects(organization=org).only('id')] ids = reuses_ids + datasets_ids qs = Discussion.objects(subject__in=ids).order_by('-created') return list(qs)
def get(self, org): '''List organization issues''' reuses_ids = [r.id for r in Reuse.objects(organization=org).only('id')] datasets_ids = [d.id for d in Dataset.objects(organization=org).only('id')] ids = reuses_ids + datasets_ids qs = Issue.objects(subject__in=ids).order_by('-created') return list(qs)
def home(): context = { 'spd_datasets': Dataset.objects.filter(badges__kind='spd'), 'recent_datasets': Dataset.objects.visible(), 'recent_reuses': Reuse.objects(featured=True).visible(), 'last_post': Post.objects.published().first() } processor = theme.current.get_processor('home') context = processor(context) return theme.render('home.html', **context)
def home(): context = { 'recent_datasets': Dataset.objects.visible(), 'recent_reuses': Reuse.objects(featured=True).visible(), 'last_post': Post.objects.published().first(), 'rdf_links': [ (RDF_MIME_TYPES[fmt], url_for('site.rdf_catalog_format', format=ext)) for (fmt, ext) in RDF_EXTENSIONS.items() ] } processor = theme.current.get_processor('home') context = processor(context) return theme.render('home.html', **context)
def home(): context = { 'recent_datasets': Dataset.objects.visible(), 'recent_reuses': Reuse.objects(featured=True).visible(), 'last_post': Post.objects.published().first(), 'rdf_links': [ (RDF_MIME_TYPES[fmt], url_for('site.rdf_catalog_format', format=ext)) for (fmt, ext) in RDF_EXTENSIONS.items() ] } processor = theme.current.get_processor('home') context = processor(context) return theme.render('home.html', **context)
def migrate(db): log.info('Processing datasets.') datasets = Dataset.objects().no_cache().timeout(False) for dataset in datasets: for badge in UNUSED_BADGES: if dataset.get_badge(badge): dataset.remove_badge(badge) log.info('Processing reuses.') reuses = Reuse.objects().no_cache().timeout(False) for reuse in reuses: for badge in UNUSED_BADGES: if reuse.get_badge(badge): reuse.remove_badge(badge) log.info('Completed.')
def render(): '''Force (re)rendering stored images''' from udata.core.organization.models import Organization from udata.core.post.models import Post from udata.core.reuse.models import Reuse from udata.core.user.models import User header('Rendering images') count = Counter() total = Counter() organizations = Organization.objects(logo__exists=True) total['orgs'] = organizations.count() log.info('Processing {0} organizations logos'.format(total['orgs'])) for org in organizations: count['orgs'] += render_or_skip(org, 'logo') users = User.objects(avatar__exists=True) total['users'] = users.count() log.info('Processing {0} user avatars'.format(total['users'])) for user in users: count['users'] += render_or_skip(user, 'avatar') posts = Post.objects(image__exists=True) total['posts'] = posts.count() log.info('Processing {0} post images'.format(total['posts'])) for post in posts: count['posts'] += render_or_skip(post, 'image') reuses = Reuse.objects(image__exists=True) total['reuses'] = reuses.count() log.info('Processing {0} reuse images'.format(total['reuses'])) for reuse in reuses: count['reuses'] += render_or_skip(reuse, 'image') log.info('''Summary: Organization logos: {count[orgs]}/{total[orgs]} User avatars: {count[users]}/{total[users]} Post images: {count[posts]}/{total[posts]} Reuse images: {count[reuses]}/{total[reuses]} '''.format(count=count, total=total)) success('Images rendered')
def render(): '''Force (re)rendering stored images''' from udata.core.organization.models import Organization from udata.core.post.models import Post from udata.core.reuse.models import Reuse from udata.core.user.models import User header('Rendering images') count = Counter() total = Counter() organizations = Organization.objects(logo__exists=True) total['orgs'] = organizations.count() log.info('Processing {0} organizations logos'.format(total['orgs'])) for org in organizations: count['orgs'] += render_or_skip(org, 'logo') users = User.objects(avatar__exists=True) total['users'] = users.count() log.info('Processing {0} user avatars'.format(total['users'])) for user in users: count['users'] += render_or_skip(user, 'avatar') posts = Post.objects(image__exists=True) total['posts'] = posts.count() log.info('Processing {0} post images'.format(total['posts'])) for post in posts: count['posts'] += render_or_skip(post, 'image') reuses = Reuse.objects(image__exists=True) total['reuses'] = reuses.count() log.info('Processing {0} reuse images'.format(total['reuses'])) for reuse in reuses: count['reuses'] += render_or_skip(reuse, 'image') log.info('''Summary: Organization logos: {count[orgs]}/{total[orgs]} User avatars: {count[users]}/{total[users]} Post images: {count[posts]}/{total[posts]} Reuse images: {count[reuses]}/{total[reuses]} '''.format(count=count, total=total)) success('Images rendered')
def render(): '''Force (re)rendering stored images''' print(cyan('Rendering images')) count = Counter() total = Counter() organizations = Organization.objects(logo__exists=True) total['orgs'] = organizations.count() print(white('Processing {0} organizations logos'.format(total['orgs']))) for org in organizations: count['orgs'] += render_or_skip(org, 'logo') users = User.objects(avatar__exists=True) total['users'] = users.count() print(white('Processing {0} user avatars'.format(total['users']))) for user in users: count['users'] += render_or_skip(user, 'avatar') posts = Post.objects(image__exists=True) total['posts'] = posts.count() print(white('Processing {0} post images'.format(total['posts']))) for post in posts: count['posts'] += render_or_skip(post, 'image') reuses = Reuse.objects(image__exists=True) total['reuses'] = reuses.count() print(white('Processing {0} reuse images'.format(total['reuses']))) for reuse in reuses: count['reuses'] += render_or_skip(reuse, 'image') print(white('Summary:')) print(''' Organization logos: {count[orgs]}/{total[orgs]} User avatars: {count[users]}/{total[users]} Post images: {count[posts]}/{total[posts]} Reuse images: {count[reuses]}/{total[reuses]} '''.format(count=count, total=total)) print(green('Images rendered'))
def count_max_reuse_followers(self): reuse = (Reuse.objects(metrics__followers__gt=0).visible().order_by( '-metrics.followers').first()) self.metrics[ 'max_reuse_followers'] = reuse.metrics['followers'] if reuse else 0 self.save()
def count_max_reuse_datasets(self): reuse = (Reuse.objects(metrics__datasets__gt=0).visible().order_by( '-metrics.datasets').first()) self.metrics[ 'max_reuse_datasets'] = reuse.metrics['datasets'] if reuse else 0 self.save()