def invitation(request): system_message = None if request.POST: form = InvitationForm(request.POST) if form.is_valid() == False: system_message = "Error" else: email = form.cleaned_data['email'] if not request.POST.get('promotion', ''): promotion = 'INNOHUB' else: promotion = request.POST['promotion'] p = Promotion.objects.get(code=promotion) promotion_id = p.pk uid = uuid.uuid4() try: Invitation.objects.create( email=email, signup_key=uid, promotion_id=promotion_id) queue_internal_email_alert( INTERNAL_INVITATION_REQUEST_SUBJECT, INTERNAL_INVITATION_REQUEST_BODY, INVITATION_EVENT) #system_message = 'Thank you! We will notify you when your request has been processed.' return HttpResponseRedirect('/manager/invitation/success/') ''' return render_to_response('system.html', { 'system_message': system_message, 'top_menu': 'landing' }, context_instance=RequestContext(request)) ''' except IntegrityError: system_message = "Email already exists." log.warn(system_message) form = InvitationForm() else: form = InvitationForm() return render_to_response('invitation.html', { 'system_message': system_message, 'form': form, }, context_instance=RequestContext(request))
def item_new(request, ticket_id=None): system_message = None if request.POST: ticket_id = request.POST["ticket_id"] profile_id = request.session["profile_id"] ticket = Ticket.objects.get(pk=ticket_id) ticket_profile_id = ticket.profile_id subject = "RE: " + ticket.short_desc item_type_id = 1 # hard code to 1= internal form = ItemForm(request.POST) if form.is_valid(): comment = form.cleaned_data["comment"] Item.objects.create(ticket_id=ticket_id, profile_id=profile_id, item_type_id=item_type_id, comment=comment) if profile_id == ticket_profile_id: # response from customer queue_internal_email_alert(subject, comment, SUPPORT_TICKET_CUSTOMER_REPLY) else: # reply from staff, send email to customer profile = Profile.objects.get(pk=ticket_profile_id) email = profile.email plaintext = get_template("email/support_response.txt") d = Context({"first_name": profile.first_name, "ticket_id": ticket_id, "comment": comment}) text_content = plaintext.render(d) queue_email(subject, text_content, email, SUPPORT_TICKET_REPLY) system_message = "Reply added" return ticket_detail(request, ticket_id) else: system_message = "Error" return render_to_response( "support_item_new.html", {"system_message": system_message, "ticket_id": ticket_id, "form": form}, context_instance=RequestContext(request), ) else: form = ItemForm() return render_to_response( "support_item_new.html", {"system_message": system_message, "ticket_id": ticket_id, "form": form}, context_instance=RequestContext(request), )
def ticket_new(request): system_message = None if request.POST: form = TicketForm(request.POST) if form.is_valid(): profile_id = request.session["profile_id"] comment = form.cleaned_data["comment"] short_desc = form.cleaned_data["short_desc"] Ticket.objects.create(profile_id=profile_id, short_desc=short_desc, comment=comment) queue_internal_email_alert(short_desc, comment, SUPPORT_TICKET_NEW_EVENT) system_message = "Support request submitted" else: system_message = "Error" else: form = TicketForm() return render_to_response( "support_ticket_new.html", {"system_message": system_message, "form": form}, context_instance=RequestContext(request), )