Skip to content

Commit

Permalink
publications: Apply flake8 hint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Aug 13, 2021
1 parent ca70de3 commit fe8b55e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions mpicms/publications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

from modelcluster.models import ClusterableModel


class LatestFirstOrderable(Orderable):
def save(self, *args, **kwargs):
if self.pk is None:
self.sort_order = self.__class__.objects.aggregate(models.Min('sort_order'))['sort_order__min'] - 1
super(Orderable, self).save(*args, **kwargs)

class Meta:
abstract = True


@register_snippet
class Publication(index.Indexed, ClusterableModel, LatestFirstOrderable):
title = RichTextField(_('title'), features=['bold', 'italic', 'link'])
Expand Down
11 changes: 6 additions & 5 deletions mpicms/publications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .models import Publication


class PublicationsFeedView(View):

# IMPORTANT: Quick hack to get experiments going, This assumes, that the
Expand All @@ -25,10 +26,10 @@ def get(self, request, *args, **kwargs):
response.write('<publication-list>\n')
for item in Publication.objects.order_by('sort_order')[:3]:
response.write(f' <publication doi="{item.doi}">\n')
response.write(f' <authors>{item.authors}</authors>\n');
response.write(f' <title>{item.title}</title>\n');
response.write(f' <source>{item.source}</source>\n');
response.write(f' <groups>{item.groups}</groups>\n');
response.write(f' <authors>{item.authors}</authors>\n')
response.write(f' <title>{item.title}</title>\n')
response.write(f' <source>{item.source}</source>\n')
response.write(f' <groups>{item.groups}</groups>\n')
response.write(' </publication>\n')
response.write('</publication-list>\n')
return response;
return response

0 comments on commit fe8b55e

Please sign in to comment.