Fixed: #2669 Membership date range is incorrect.Fixed: #2671 Error when user try to access membership view without having one.Fixed: #2672: As I user want to know my next membership date range.Fixed #2673: Enable new Main DG index.Fixed #2657 :cancel membership button style fix

This commit is contained in:
Levi 2016-10-23 18:09:01 -05:00
parent 08d1077ad0
commit 735089785b
5 changed files with 56 additions and 16 deletions

View file

@ -102,16 +102,26 @@ class MembershipOrder(Ordereable, models.Model):
end_date = models.DateField() end_date = models.DateField()
@classmethod @classmethod
def current_membership(cls, user): def current_membership_dates(cls, user):
last_membership_payment = cls.objects.\ last_membership_payment = cls.objects.\
filter(customer__user=user).last() filter(customer__user=user).last()
# start_date = last_payment.created_at if not last_membership_payment:
# _, days_in_month = calendar.monthrange(start_date.year, return [None, None]
# start_date.month)
# start_date.replace(day=1)
# end_date = start_date + timedelta(days=days_in_month)
return last_membership_payment.start_date, last_membership_payment.end_date return last_membership_payment.start_date, last_membership_payment.end_date
@classmethod
def next_membership_dates(cls, user):
current_start_date, current_end_date = cls.current_membership_dates(user)
if not current_start_date or not current_end_date:
return [None, None]
next_start_date = current_end_date + relativedelta(months=1)
_, days_in_month = calendar.monthrange(next_start_date.year,
next_start_date.month)
next_start_date = next_start_date.replace(day=1)
next_end_date = next_start_date + timedelta(days=days_in_month)
return next_start_date, next_end_date
def first_membership_range_date(self): def first_membership_range_date(self):
start_date = self.created_at start_date = self.created_at
_, days_in_month = calendar.monthrange(start_date.year, _, days_in_month = calendar.monthrange(start_date.year,

View file

@ -20,7 +20,8 @@
<div class="container-fluid darkened-container"> <div class="container-fluid darkened-container">
<h3 class="intro-small"> <h3 class="intro-small">
Book a date today and dive in</h3> Book a date today and dive in</h3>
<form class="form-inline"> <a href="{% url 'digitalglarus:booking' %}" class="btn btn-primary">Join now</a>
<!-- <form class="form-inline">
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="exampleInputPassword3">Pick a date</label> <label class="sr-only" for="exampleInputPassword3">Pick a date</label>
<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Pick a date"> <input type="password" class="form-control" id="exampleInputPassword3" placeholder="Pick a date">
@ -30,7 +31,7 @@
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">book a date</button> <button type="submit" class="btn btn-primary">book a date</button>
</form> </form> -->
</div> </div>
</header> </header>
@ -187,7 +188,7 @@
Join our community. Be our member now! Join our community. Be our member now!
<br> <br>
<br> <br>
<a href="http://startbootstrap.com/template-overviews/creative/" class="btn btn-default btn-primary sr-button"> Sign Up </a> <a href="{% url 'digitalglarus:signup' %}" class="btn btn-default btn-primary sr-button"> Sign Up </a>
</div> </div>
</div> </div>
</aside> </aside>

View file

@ -10,6 +10,15 @@
margin-top:10%; margin-top:10%;
} }
#cancel-subscription-modal .modal-header{
border-bottom: none;
}
#cancel-subscription-modal .modal-footer{
border-top: none;
text-align: center;
}
</style> </style>
<section id="price"> <section id="price">
@ -46,7 +55,7 @@
<div class="modal-body"> <div class="modal-body">
<p>Do you want to cancel your subscription?</p> <p>Do you want to cancel your subscription?</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer text-center">
<button type="button" class="btn btn-primary btn-grey" data-dismiss="modal">No</button> <button type="button" class="btn btn-primary btn-grey" data-dismiss="modal">No</button>
<button type="submit" class="btn btn-primary">Yes</button> <button type="submit" class="btn btn-primary">Yes</button>
</div> </div>

View file

@ -15,7 +15,11 @@
<h2 class="member-name">{{request.user.name}}</h2> <h2 class="member-name">{{request.user.name}}</h2>
<hr class="greyline-long"> <hr class="greyline-long">
<h2 class="order-head">Current Membership</h2> <h2 class="order-head">Current Membership</h2>
<h2 class="member-name">{{membership_start_date|date}}-{{membership_end_date|date}}</h2> {% if membership_start_date and membership_end_date%}
<h2 class="member-name">{{membership_start_date|date}}-{{membership_end_date|date}}</h2>
{% else %}
<h2 class="member-name">You don't have an active membership</h2>
{% endif %}
<hr class="greyline-long"> <hr class="greyline-long">
<h2 class="order-head">Orders history</h2> <h2 class="order-head">Orders history</h2>
<table class="table"> <table class="table">
@ -43,16 +47,30 @@
<h2 class="history-name"> <h2 class="history-name">
{{request.user.name}} {{request.user.name}}
</h2> </h2>
{% if billing_address %}
<h2 class="history-name"> <h2 class="history-name">
{{billing_address.street_address}},{{billing_address.postal_code}}<br> {{billing_address.street_address}},{{billing_address.postal_code}}<br>
{{billing_address.city}}, {{billing_address.country}}. {{billing_address.city}}, {{billing_address.country}}.
</h2> </h2>
{% else %}
<h2 class="history-name">
Edit your billing address
</h2>
{% endif %}
<hr class="greyline-long"> <hr class="greyline-long">
<h2 class="order-head">Your Next Membership</h2> <h2 class="order-head">Your Next Membership</h2>
{% if next_membership_start_date and next_membership_end_date%}
<h2 class="history-name"> <h2 class="history-name">
Dates: {{membership_start_date|date}} - {{membership_end_date|date}}<br> Dates: {{next_membership_start_date|date}} - {{next_membership_end_date|date}}<br>
</h2> </h2>
{% else %}
<h2 class="history-name">
You are not a member yet
</h2>
{% endif %}
<div class="edit-button"> <div class="edit-button">
<a class="btn btn-primary btn-grey btn-deactivate print" href="{% url 'digitalglarus:membership_deactivate' %}">Deactivate</a> <a class="btn btn-primary btn-grey btn-deactivate print" href="{% url 'digitalglarus:membership_deactivate' %}">Deactivate</a>

View file

@ -42,7 +42,7 @@ from .mixins import MembershipRequiredMixin, IsNotMemberMixin
class IndexView(TemplateView): class IndexView(TemplateView):
template_name = "digitalglarus/old_index.html" template_name = "digitalglarus/index.html"
class LoginView(LoginViewMixin): class LoginView(LoginViewMixin):
@ -488,11 +488,14 @@ class MembershipOrdersListView(LoginRequiredMixin, ListView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(MembershipOrdersListView, self).get_context_data(**kwargs) context = super(MembershipOrdersListView, self).get_context_data(**kwargs)
start_date, end_date = MembershipOrder.current_membership(self.request.user) start_date, end_date = MembershipOrder.current_membership_dates(self.request.user)
next_start_date, next_end_date = MembershipOrder.next_membership_dates(self.request.user)
current_billing_address = self.request.user.billing_addresses.filter(current=True).last() current_billing_address = self.request.user.billing_addresses.filter(current=True).last()
context.update({ context.update({
'membership_start_date': start_date, 'membership_start_date': start_date,
'membership_end_date': end_date, 'membership_end_date': end_date,
'next_membership_start_date': next_start_date,
'next_membership_end_date': next_end_date,
'billing_address': current_billing_address 'billing_address': current_billing_address
}) })
return context return context
@ -602,7 +605,6 @@ class ContactView(FormView):
return super(ContactView, self).form_valid(form) return super(ContactView, self).form_valid(form)
class AboutView(TemplateView): class AboutView(TemplateView):
template_name = "digitalglarus/about.html" template_name = "digitalglarus/about.html"