diff options
author | luxagraf <sng@luxagraf.net> | 2018-02-05 13:38:59 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-02-05 13:38:59 -0600 |
commit | 3398e7349e2bafddaa491c01f4c16c6dae14cd00 (patch) | |
tree | 0ae25201ce6fc50146dff819b03819ddce148cfe /app/sketches | |
parent | ad112641f01a0fd36d0b738b6903dea3eadbf000 (diff) |
abstracted the next prev links into utils so now they work for every
model that implements a get_%S_admin_link method and loads the JS
Diffstat (limited to 'app/sketches')
-rw-r--r-- | app/sketches/admin.py | 2 | ||||
-rw-r--r-- | app/sketches/models.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/sketches/admin.py b/app/sketches/admin.py index 41715aa..07a2e6a 100644 --- a/app/sketches/admin.py +++ b/app/sketches/admin.py @@ -34,7 +34,7 @@ class SketchAdmin(OLAdminBase): default_zoom = 10 class Media: - js = ('image-loader.js',) + js = ('image-loader.js', 'next-prev-links.js') diff --git a/app/sketches/models.py b/app/sketches/models.py index c7d28a5..2d7f9ac 100644 --- a/app/sketches/models.py +++ b/app/sketches/models.py @@ -58,6 +58,18 @@ class Sketch(models.Model): def get_next_published(self): return self.get_next_by_pub_date() + @property + def get_previous_admin_url(self): + n = self.get_previous_by_pub_date() + return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] ) + + @property + def get_next_admin_url(self): + model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name) + try: + return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] ) + except model.DoesNotExist: + return '' def save(self, *args, **kwargs): md = render_images(self.body_markdown) |