diff options
-rw-r--r-- | app/src/models.py | 8 | ||||
-rw-r--r-- | app/src/views.py | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/app/src/models.py b/app/src/models.py index 2cf6e23..1686301 100644 --- a/app/src/models.py +++ b/app/src/models.py @@ -1,6 +1,6 @@ from django.db import models from django.contrib.sitemaps import Sitemap -from django.contrib.syndication.views import Feed +from django.conf import settings from jrnl.models import image_url_replace, extract_images import markdown import datetime @@ -69,8 +69,6 @@ class Entry(models.Model): def get_next_published(self): return self.get_next_by_pub_date(status__exact=1) - 'codehilite(css_class=highlight,linenums=False,guess_lang=True,use_pygments=True)' - def save(self): md = image_url_replace(self.body_markdown) self.body_html = markdown.markdown(md, extensions=[ @@ -124,6 +122,10 @@ class Book(models.Model): def get_absolute_url(self): return "/src/books/%s" % (self.slug) + def get_image_url(self): + img = self.image.url.split('src/')[1] + return '%ssrc/%s' % (settings.IMAGES_URL, img) + def save(self): md = image_url_replace(self.body_markdown) self.body_html = markdown.markdown(md, extensions=[ diff --git a/app/src/views.py b/app/src/views.py index 95ddafa..203a021 100644 --- a/app/src/views.py +++ b/app/src/views.py @@ -27,9 +27,13 @@ class BookDetailView(DetailView): # Call the base implementation first to get a context context = super(BookDetailView, self).get_context_data(**kwargs) book = self.get_object() + if book.price_sale < book.price: + price = book.price_sale + else: + price = book.price paypal_dict = { "business": settings.PAYPAL_RECEIVER_EMAIL, - "amount": book.price, + "amount": price, "item_name": book.title, "invoice": "unique-invoice-id", "notify_url": "https://www.example.com" + reverse('src:paypal-ipn'), |