From a846f42bf6050ba80e7087ccfd0b62c20431319a Mon Sep 17 00:00:00 2001 From: Levi Date: Sun, 29 May 2016 13:37:43 -0500 Subject: [PATCH] Added mark a notification as read feature, Fixed some errors --- dynamicweb/settings/base.py | 1 + hosting/models.py | 14 ++- hosting/templates/hosting/base_short.html | 6 +- hosting/templates/hosting/notifications.html | 90 ++++++++++++++++++++ hosting/urls.py | 8 +- hosting/views.py | 44 ++++++++-- requirements.txt | 1 + 7 files changed, 153 insertions(+), 11 deletions(-) create mode 100644 hosting/templates/hosting/notifications.html diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index db2912bd..ab2d6763 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -54,6 +54,7 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'easy_thumbnails', 'utils', + 'stored_messages', 'mptt', 'parler', 'taggit', diff --git a/hosting/models.py b/hosting/models.py index ef33c056..518ba175 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -3,12 +3,13 @@ import os from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.functional import cached_property -from membership.models import StripeCustomer -from utils.models import BillingAddress + from Crypto.PublicKey import RSA +from stored_messages.settings import stored_messages_settings - +from membership.models import StripeCustomer +from utils.models import BillingAddress from .managers import VMPlansManager @@ -118,6 +119,13 @@ class VirtualMachinePlan(models.Model): name = 'vm-%s' % self.id return name + @cached_property + def notifications(self): + stripe_customer = StripeCustomer.objects.get(hostingorder__vm_plan=self) + backend = stored_messages_settings.STORAGE_BACKEND() + messages = backend.inbox_list(stripe_customer.user) + return messages + @classmethod def create(cls, data, user): instance = cls.objects.create(**data) diff --git a/hosting/templates/hosting/base_short.html b/hosting/templates/hosting/base_short.html index 874b590f..55466815 100644 --- a/hosting/templates/hosting/base_short.html +++ b/hosting/templates/hosting/base_short.html @@ -71,7 +71,11 @@ My Orders - +
  • + + Notifications + +