def decline(request, pk): if request.method == "POST": b = get_object_or_404(User, pk=pk) f = PartnerForm(request.POST) f.id = pk #send email notification subject = "East Scarborough Storefront - Account Denied" message = "Dear " + b.username + ",\n\nYour account request at East Scarborough Storefront has been denied.\nPlease call the Storefront for more details.\n\nThank you" b.email_user(subject, message, settings.DEFAULT_FROM_EMAIL) b.delete() return render(request, 'juakstore/admin_decline.html') else: form = BookingForm() return HttpResponseRedirect(reverse('juakstore/admin_decline.html', args=(pk,)))
def accept(request, pk): if request.method == "POST": b = get_object_or_404(User, pk=pk) f = PartnerForm(request.POST) f.id = pk b.is_active = True b.save() #send email notification subject = "East Scarborough Storefront - Account Approved" current_site = Site.objects.get_current() text_content = "Dear " + b.username + ",\n\nYour account request at East Scarborough Storefront has been approved.\nYou can login at " + current_site.name + ".\n\nThank you" html_content = 'Dear ' + b.username + ',<br><br>Your account request at East Scarborough Storefront has been approved.<br>You can login at <a href="http://' + current_site.domain + '">' + current_site.name + '</a>.<br><br>Thank you' msg = EmailMultiAlternatives(subject, text_content, settings.DEFAULT_FROM_EMAIL, [b.email]) msg.attach_alternative(html_content, "text/html") msg.send() return render(request, 'juakstore/admin_accept.html', {'user': b}) else: form = BookingForm() return HttpResponseRedirect(reverse('juakstore/admin_accept.html', args=(pk,)))