Merge pull request #135 from levivm/feature/new_digitalglarus

Final fixes to DG
This commit is contained in:
Levi Velázquez 2016-10-23 18:11:57 -05:00 committed by GitHub
commit e2597f3ed7
5 changed files with 56 additions and 16 deletions

View file

@ -102,16 +102,26 @@ class MembershipOrder(Ordereable, models.Model):
end_date = models.DateField()
@classmethod
def current_membership(cls, user):
def current_membership_dates(cls, user):
last_membership_payment = cls.objects.\
filter(customer__user=user).last()
# start_date = last_payment.created_at
# _, days_in_month = calendar.monthrange(start_date.year,
# start_date.month)
# start_date.replace(day=1)
# end_date = start_date + timedelta(days=days_in_month)
if not last_membership_payment:
return [None, None]
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):
start_date = self.created_at
_, days_in_month = calendar.monthrange(start_date.year,

View file

@ -20,7 +20,8 @@
<div class="container-fluid darkened-container">
<h3 class="intro-small">
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">
<label class="sr-only" for="exampleInputPassword3">Pick a date</label>
<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Pick a date">
@ -30,7 +31,7 @@
</div>
</div>
<button type="submit" class="btn btn-primary">book a date</button>
</form>
</form> -->
</div>
</header>
@ -187,7 +188,7 @@
Join our community. Be our member now!
<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>
</aside>

View file

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

View file

@ -15,7 +15,11 @@
<h2 class="member-name">{{request.user.name}}</h2>
<hr class="greyline-long">
<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">
<h2 class="order-head">Orders history</h2>
<table class="table">
@ -43,16 +47,30 @@
<h2 class="history-name">
{{request.user.name}}
</h2>
{% if billing_address %}
<h2 class="history-name">
{{billing_address.street_address}},{{billing_address.postal_code}}<br>
{{billing_address.city}}, {{billing_address.country}}.
</h2>
{% else %}
<h2 class="history-name">
Edit your billing address
</h2>
{% endif %}
<hr class="greyline-long">
<h2 class="order-head">Your Next Membership</h2>
{% if next_membership_start_date and next_membership_end_date%}
<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>
{% else %}
<h2 class="history-name">
You are not a member yet
</h2>
{% endif %}
<div class="edit-button">
<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):
template_name = "digitalglarus/old_index.html"
template_name = "digitalglarus/index.html"
class LoginView(LoginViewMixin):
@ -488,11 +488,14 @@ class MembershipOrdersListView(LoginRequiredMixin, ListView):
def get_context_data(self, **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()
context.update({
'membership_start_date': start_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
})
return context
@ -602,7 +605,6 @@ class ContactView(FormView):
return super(ContactView, self).form_valid(form)
class AboutView(TemplateView):
template_name = "digitalglarus/about.html"