Manual merge of ungleich/master into opennebula-integration
This commit is contained in:
parent
d10285e23d
commit
d537fcb118
227 changed files with 25686 additions and 482 deletions
|
|
@ -1,9 +1,5 @@
|
|||
import json
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.forms import ModelForm
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
|
@ -12,27 +8,19 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
|||
from django.utils.translation import get_language
|
||||
from djangocms_blog.models import Post
|
||||
from django.contrib import messages
|
||||
from django.http import JsonResponse
|
||||
from django.views.generic import View, DetailView, ListView, DeleteView
|
||||
|
||||
|
||||
from django.views.generic import DetailView, ListView
|
||||
from .models import Supporter
|
||||
from .mixins import ChangeMembershipStatusMixin
|
||||
from utils.forms import ContactUsForm
|
||||
from utils.mailer import BaseEmail
|
||||
|
||||
from django.views.generic.edit import FormView
|
||||
from membership.calendar.calendar import BookCalendar
|
||||
from membership.models import Calendar as CalendarModel, StripeCustomer
|
||||
|
||||
|
||||
from membership.models import StripeCustomer
|
||||
from utils.views import LoginViewMixin, SignupViewMixin, \
|
||||
PasswordResetViewMixin, PasswordResetConfirmViewMixin
|
||||
from utils.forms import PasswordResetRequestForm, UserBillingAddressForm
|
||||
from utils.forms import PasswordResetRequestForm, UserBillingAddressForm, EditCreditCardForm
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from utils.models import UserBillingAddress
|
||||
|
||||
|
||||
from .forms import LoginForm, SignupForm, MembershipBillingForm, BookingDateForm,\
|
||||
BookingBillingForm, CancelBookingForm
|
||||
|
||||
|
|
@ -41,48 +29,6 @@ from .models import MembershipType, Membership, MembershipOrder, Booking, Bookin
|
|||
|
||||
from .mixins import MembershipRequiredMixin, IsNotMemberMixin
|
||||
|
||||
class Probar(LoginRequiredMixin, UpdateView):
|
||||
template_name='digitalglarus/membership_deactivated.html'
|
||||
model = Membership
|
||||
success_url = reverse_lazy('digitalglarus:probar')
|
||||
|
||||
|
||||
|
||||
class ValidateUser(TemplateView):
|
||||
#print ("ENTRE AQUI AL MENOS Y",pk)
|
||||
template_name = "digitalglarus/signup.html"
|
||||
#form_class = SignupForm
|
||||
success_url = reverse_lazy('digitalglarus:login')
|
||||
#if request.method == 'POST':
|
||||
#u = U.objects.get(pk = pk)
|
||||
#u.is_active = True
|
||||
#u.save()
|
||||
#messages.info(request, 'Usuario Activado')
|
||||
#Log('activar','usuario',request)
|
||||
#resp = dict()
|
||||
#resp['msg'] = 0 #0 para exito
|
||||
#return HttpResponse(json.dumps(resp), content_type ='application/json')
|
||||
|
||||
class ValidateView(SignupViewMixin):
|
||||
template_name = "digitalglarus/signup.html"
|
||||
form_class = SignupForm
|
||||
success_url = reverse_lazy('digitalglarus:login')
|
||||
|
||||
|
||||
#def activarUsuario(request, pk):
|
||||
#if request.method == 'POST':
|
||||
# u = U.objects.get(pk = pk)
|
||||
# u.is_active = True
|
||||
# u.save()
|
||||
# messages.info(request, 'Usuario Activado')
|
||||
# Log('activar','usuario',request)
|
||||
#resp = dict()
|
||||
#resp['msg'] = 0 #0 para exito
|
||||
#return HttpResponse(json.dumps(resp), content_type ='application/json')
|
||||
|
||||
class TermsAndConditions(TemplateView):
|
||||
template_name ="digitalglarus/terms.html"
|
||||
|
||||
|
||||
class IndexView(TemplateView):
|
||||
template_name = "digitalglarus/index.html"
|
||||
|
|
@ -145,6 +91,32 @@ class HistoryView(TemplateView):
|
|||
return context
|
||||
|
||||
|
||||
class EditCreditCardView(FormView):
|
||||
template_name = "digitalglarus/edit_credit_card.html"
|
||||
form_class = EditCreditCardForm
|
||||
success_url = reverse_lazy('digitalglarus:booking_payment')
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super(EditCreditCardView, self).get_context_data(*args, **kwargs)
|
||||
context.update({
|
||||
'stripe_key': settings.STRIPE_API_PUBLIC_KEY
|
||||
})
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
token = form.cleaned_data.get('token')
|
||||
user = self.request.user
|
||||
customer = user.stripecustomer
|
||||
stripe_utls = StripeUtils()
|
||||
card_response = stripe_utls.update_customer_card(customer.stripe_id, token)
|
||||
new_card_data = card_response.get('response_object')
|
||||
self.request.session.update({
|
||||
'new_change_credit_card': new_card_data
|
||||
})
|
||||
|
||||
return super(EditCreditCardView, self).form_valid(form)
|
||||
|
||||
|
||||
class BookingSelectDatesView(LoginRequiredMixin, MembershipRequiredMixin, FormView):
|
||||
template_name = "digitalglarus/booking.html"
|
||||
form_class = BookingDateForm
|
||||
|
|
@ -228,9 +200,16 @@ class BookingPaymentView(LoginRequiredMixin, MembershipRequiredMixin, FormView):
|
|||
user = self.request.user
|
||||
last_booking_order = BookingOrder.objects.filter(customer__user=user).last()
|
||||
last_membership_order = MembershipOrder.objects.filter(customer__user=user).last()
|
||||
credit_card_data = last_booking_order.get_booking_cc_data() if last_booking_order \
|
||||
and last_booking_order.get_booking_cc_data() \
|
||||
else last_membership_order.get_membership_order_cc_data()
|
||||
|
||||
# check if user changes his credit card
|
||||
credit_card_data = self.request.session.get('new_change_credit_card')
|
||||
# import pdb
|
||||
# pdb.set_trace()
|
||||
|
||||
if not credit_card_data:
|
||||
credit_card_data = last_booking_order.get_booking_cc_data() if last_booking_order \
|
||||
and last_booking_order.get_booking_cc_data() \
|
||||
else last_membership_order.get_membership_order_cc_data()
|
||||
|
||||
booking_data.update({
|
||||
'credit_card_data': credit_card_data if credit_card_data else None,
|
||||
|
|
@ -252,8 +231,6 @@ class BookingPaymentView(LoginRequiredMixin, MembershipRequiredMixin, FormView):
|
|||
|
||||
# if not credit_card_needed:
|
||||
# Get or create stripe customer
|
||||
# import pdb
|
||||
# pdb.set_trace()
|
||||
customer = StripeCustomer.get_or_create(email=self.request.user.email,
|
||||
token=token)
|
||||
if not customer:
|
||||
|
|
@ -530,11 +507,11 @@ class UserBillingAddressView(LoginRequiredMixin, UpdateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UserBillingAddressView, self).get_context_data(**kwargs)
|
||||
current_billing_address = self.request.user.billing_addresses.first()
|
||||
current_billing_address = self.request.user.billing_addresses.all().first()
|
||||
context.update({
|
||||
'current_billing_address': current_billing_address
|
||||
})
|
||||
return current_billing_address
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
"""
|
||||
|
|
@ -562,7 +539,8 @@ class UserBillingAddressView(LoginRequiredMixin, UpdateView):
|
|||
return form_kwargs
|
||||
|
||||
def get_object(self):
|
||||
current_billing_address = self.request.user.billing_addresses.filter(current=True).last()
|
||||
current_billing_address = self.request.user.\
|
||||
billing_addresses.filter(current=True).last()
|
||||
# if not current_billing_address:
|
||||
# raise AttributeError("Billing Address does not exists")
|
||||
return current_billing_address
|
||||
|
|
@ -620,23 +598,6 @@ class OrdersMembershipDetailView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
# class BookingCancelView(FormView):
|
||||
# success_message = "Your booking has been cancelled"
|
||||
# model = BookingOrder
|
||||
# form_class = CancelBookingForm
|
||||
|
||||
# def get_success_url(self):
|
||||
# pk = self.kwargs.get(self.pk_url_kwarg)
|
||||
# return reverse_lazy('digitalglarus:booking_orders_list', kwargs={'pk': pk})
|
||||
|
||||
# def form_valid(self, form):
|
||||
# booking_order = self.get_object()
|
||||
# # booking_order.cancel()
|
||||
# request = self.request
|
||||
|
||||
# return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
|
||||
class OrdersBookingDetailView(LoginRequiredMixin, UpdateView):
|
||||
template_name = "digitalglarus/booking_orders_detail.html"
|
||||
context_object_name = "order"
|
||||
|
|
@ -747,19 +708,6 @@ class BookingOrdersListView(LoginRequiredMixin, ListView):
|
|||
return queryset
|
||||
|
||||
|
||||
############## OLD VIEWS
|
||||
class CalendarApi(View):
|
||||
def get(self,request,month,year):
|
||||
calendar = BookCalendar(request.user,requested_month=month).formatmonth(int(year),int(month))
|
||||
ret = {'calendar':calendar,'month':month,'year':year}
|
||||
return JsonResponse(ret)
|
||||
|
||||
def post(self,request):
|
||||
pd = json.loads(request.POST.get('data',''))
|
||||
ret = {'status':'success'}
|
||||
CalendarModel.add_dates(pd,request.user)
|
||||
return JsonResponse(ret)
|
||||
|
||||
class ContactView(FormView):
|
||||
template_name = 'contact.html'
|
||||
form_class = ContactUsForm
|
||||
|
|
@ -772,25 +720,7 @@ class ContactView(FormView):
|
|||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
return super(ContactView, self).form_valid(form)
|
||||
|
||||
|
||||
class AboutView(TemplateView):
|
||||
template_name = "digitalglarus/about.html"
|
||||
|
||||
def detail(request, message_id):
|
||||
p = get_object_or_404(Message, pk=message_id)
|
||||
|
||||
context = { 'message': p, }
|
||||
return render(request, 'digitalglarus/detail.html', context)
|
||||
|
||||
def about(request):
|
||||
return render(request, 'digitalglarus/about.html')
|
||||
|
||||
def home(request):
|
||||
return render(request, 'index.html')
|
||||
|
||||
def letscowork(request):
|
||||
return render(request, 'digitalglarus/letscowork.html')
|
||||
|
||||
############## OLD VIEWS
|
||||
|
||||
def blog(request):
|
||||
tags = ["digitalglarus"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue