Skip to content

Commit

Permalink
Add catalog, site, and rdmo version to views (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Jul 18, 2023
1 parent 6824ca3 commit 45319af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rdmo/views/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.db import models
from django.template import Context, Template
from django.utils.translation import gettext_lazy as _

from rdmo import __version__
from rdmo.core.models import TranslationMixin
from rdmo.core.utils import copy_model, get_pandoc_main_version, join_url
from rdmo.questions.models import Catalog
Expand Down Expand Up @@ -154,11 +156,17 @@ def is_locked(self):
def render(self, project, snapshot=None, export_format=None):
# render the template to a html string
# it is important not to use models here
site = Site.objects.get_current()
project_wrapper = ProjectWrapper(project, snapshot)
return Template(self.template).render(Context({
'project': project_wrapper,
'conditions': project_wrapper.conditions,
'format': export_format,
'rdmo_version': __version__,
'site': {
'name': site.name,
'domain': site.domain
},
'pandoc_version': get_pandoc_main_version()
}))

Expand Down
9 changes: 9 additions & 0 deletions rdmo/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ def title(self):
def description(self):
return self._project.description

@property
def catalog(self):
return {
'id': self._catalog.id,
'uri': self._catalog.uri,
'title': self._catalog.title,
'help': self._catalog.help
}

@property
def created(self):
return self._project.created
Expand Down

0 comments on commit 45319af

Please sign in to comment.