def update_status(request, id=None): ''' View to Update Status ''' from atrinsic.base.models import Organization_Status, Organization from forms import StatusUpdateForm if request.POST: form = StatusUpdateForm(request.POST) if form.is_valid(): Organization_Status.objects.create( message=form.cleaned_data['message'], organization=request.organization) referer = request.META.get('HTTP_REFERER', None) if referer == None: return HttpResponseRedirect("/publisher/") else: return HttpResponseRedirect(referer) else: form = StatusUpdateForm() return AQ_render_to_response(request, 'base/AAN_UpdateStatus.html', { 'form': form, }, context_instance=RequestContext(request)) ##################### END Update Status ########################
def update_status(request, id=None): ''' View to Update Status ''' from atrinsic.base.models import Organization_Status,Organization from forms import StatusUpdateForm if request.POST: form = StatusUpdateForm(request.POST) if form.is_valid(): Organization_Status.objects.create(message=form.cleaned_data['message'], organization=request.organization) referer = request.META.get('HTTP_REFERER', None) if referer == None: return HttpResponseRedirect("/publisher/") else: return HttpResponseRedirect(referer) else: form = StatusUpdateForm() return AQ_render_to_response(request, 'base/AAN_UpdateStatus.html', { 'form' : form, }, context_instance=RequestContext(request)) ##################### END Update Status ########################
def advertiser_messages_compose(request, id=None): ''' View to Compose Private Message. The recipient ID can be passed in the URL or through a GET variable "rid" and passing an ID on the URL for replying to a message pass''' from atrinsic.base.models import PrivateMessage, Organization_Status, Organization, MsgStatus from forms import StatusUpdateForm, AdvertiserPrivateMessageForm, PrivateMessageForm from django.db.models import Q composeTo = None if id != None: publisher_id = [PrivateMessage.objects.get(id=id).sender.id] else: publisher_id = request.REQUEST.getlist('publisher_id') if request.POST.get('MessageOrStatus', 'Msg') == 'Status': form = StatusUpdateForm(request.POST) if form.is_valid(): Organization_Status.objects.create( message=form.cleaned_data['message'], organization=request.organization) return HttpResponseRedirect('/advertiser/messages/') if request.method == "POST": if len(publisher_id) > 0: form = PrivateMessageForm(request.POST) else: form = AdvertiserPrivateMessageForm(request.POST, org=request.organization) if form.is_valid(): if not publisher_id: publisher_id = [ form.cleaned_data['receiver'], ] for p_id in publisher_id: try: publisher = Organization.objects.get(id=p_id) PrivateMessage.objects.create( subject=form.cleaned_data['subject'], date_sent=datetime.datetime.now(), message=form.cleaned_data['message'], sender=request.organization, receiver=publisher, is_active=True, sender_status=MsgStatus(pk=1), receiver_status=MsgStatus(pk=1)) except Organization.DoesNotExist: pass referer = request.META.get('HTTP_REFERER', None) if referer == None: return HttpResponseRedirect("/advertiser/messages/") else: return HttpResponseRedirect(referer) else: d = {} if 'rid' in request.GET: try: rid = int(request.GET.get('rid', 0)) except ValueError: rid = 0 if rid > 0: try: recip = Organization.objects.get(id=rid) d['receiver'] = recip.name publisher_id = [rid] except Organizaion.DoesNotExist: pass if id: try: m = PrivateMessage.objects.get(id=id, receiver=request.organization) d['subject'] = 'Re: %s' % m.subject d['receiver'] = m.sender.name d['message'] = "On %s, %s wrote:\n%s" % ( m.date_sent, m.sender.name, m.message, ) except PrivateMessage.DoesNotExist: raise Http404 if d.get('receiver'): form = PrivateMessageForm(initial=d) else: composeTo = request.GET.get("compose_to", None) form = AdvertiserPrivateMessageForm(org=request.organization, initial=d) # This is used to load the compose form within the 2nd level of lightboxes..ie, Lightbox loading a lightbox. if 'secondtier' in request.GET: secondTier = request.GET.get('secondtier') else: secondTier = 0 # Folder totals for sidebar inbox = PrivateMessage.objects.filter( receiver=request.organization.id, receiver_status=1).order_by('-date_sent') sent = PrivateMessage.objects.filter( sender=request.organization.id, sender_status=1).order_by('-date_sent') trash = PrivateMessage.objects.filter( Q(sender=request.organization.id, sender_status=3) | Q(receiver=request.organization.id, receiver_status=3)).order_by( '-date_sent') return AQ_render_to_response(request, 'advertiser/messages/compose.html', { 'form': form, 'inbox': inbox, 'trash': trash, 'sent': sent, 'publisher_id': publisher_id, 'composeTo': composeTo, 'secondTier': secondTier, }, context_instance=RequestContext(request))
def publisher_messages_compose(request, id=None): ''' View to Compose a PrivateMessage. This view can be passed multiple recipients through the GET variable "r_id" ''' from atrinsic.base.models import Organization, Organization_Status, PrivateMessage, PublisherRelationship, MsgStatus from forms import PrivateMessageForm, PublisherPrivateMessageForm, StatusUpdateForm from django.db.models import Q from django.core.mail import EmailMultiAlternatives composeTo = None if request.POST.get('MessageOrStatus', 'Msg') == 'Status': form = StatusUpdateForm(request.POST) if form.is_valid(): Organization_Status.objects.create( message=form.cleaned_data['message'], organization=request.organization) return HttpResponseRedirect('/publisher/messages/') if id != None: advertiser_id = [PrivateMessage.objects.get(id=id).sender.id] else: advertiser_id = request.REQUEST.getlist('advertiser_id') else: if id != None: advertiser_id = [PrivateMessage.objects.get(id=id).sender.id] else: advertiser_id = request.REQUEST.getlist('advertiser_id') if request.method == "POST": if len(advertiser_id) > 0: form = PrivateMessageForm(request.POST) else: form = PublisherPrivateMessageForm(request.POST, org=request.organization) if form.is_valid(): if not advertiser_id: advertiser_id = [ form.cleaned_data['receiver'], ] print "here" for p_id in advertiser_id: try: advertiser = Organization.objects.get(id=p_id) PrivateMessage.objects.create( subject=form.cleaned_data['subject'], date_sent=datetime.datetime.now(), message=form.cleaned_data['message'], sender=request.organization, receiver=advertiser, is_active=True, sender_status=MsgStatus(pk=1), receiver_status=MsgStatus(pk=1)) #For Kayak advertiser, we want to send a copy of that message. if int(advertiser_id[0]) == 711: destinations = ['*****@*****.**'] try: msg = EmailMultiAlternatives( 'MSG to Kayak.com: ' + form.cleaned_data['subject'], form.cleaned_data['message'], '*****@*****.**', destinations) msg.send() except: pass except Organization.DoesNotExist: pass referer = request.META.get('HTTP_REFERER', None) if referer == None: return HttpResponseRedirect("/publisher/messages/") else: return HttpResponseRedirect(referer) else: d = {} if 'rid' in request.GET: try: rid = int(request.GET.get('rid', 0)) except ValueError: rid = 0 if rid > 0: try: recip = Organization.objects.get(id=rid) d['receiver'] = recip.name advertiser_id = [rid] except Organizaion.DoesNotExist: pass if id: try: m = PrivateMessage.objects.get( id=id, receiver=request.organization) d['subject'] = 'Re: %s' % m.subject d['receiver'] = m.sender.name d['message'] = "On %s, %s wrote:\n%s" % ( m.date_sent, m.sender.name, m.message, ) except PrivateMessage.DoesNotExist: raise Http404 if d.get('receiver'): form = PrivateMessageForm(initial=d) elif advertiser_id: d['receiver'] = 'Multiple Recipients' form = PrivateMessageForm(initial=d) else: composeTo = request.GET.get("compose_to", None) form = PublisherPrivateMessageForm(org=request.organization, initial=d) inbox = PrivateMessage.objects.filter( receiver=request.organization.id, receiver_status=1).order_by('-date_sent') sent = PrivateMessage.objects.filter( sender=request.organization.id, sender_status=1).order_by('-date_sent') trash = PrivateMessage.objects.filter( Q(sender=request.organization.id, sender_status=3) | Q(receiver=request.organization.id, receiver_status=3)).order_by( '-date_sent') return AQ_render_to_response(request, 'publisher/messages/compose.html', { 'form': form, 'inbox': inbox, 'trash': trash, 'sent': sent, 'advertiser_id': advertiser_id, 'composeTo': composeTo, }, context_instance=RequestContext(request))
def advertiser_messages_compose(request, id=None): ''' View to Compose Private Message. The recipient ID can be passed in the URL or through a GET variable "rid" and passing an ID on the URL for replying to a message pass''' from atrinsic.base.models import PrivateMessage,Organization_Status,Organization,MsgStatus from forms import StatusUpdateForm,AdvertiserPrivateMessageForm,PrivateMessageForm from django.db.models import Q composeTo = None if id != None: publisher_id = [PrivateMessage.objects.get(id=id).sender.id] else: publisher_id = request.REQUEST.getlist('publisher_id') if request.POST.get('MessageOrStatus', 'Msg') == 'Status': form = StatusUpdateForm(request.POST) if form.is_valid(): Organization_Status.objects.create(message=form.cleaned_data['message'], organization=request.organization) return HttpResponseRedirect('/advertiser/messages/') if request.method == "POST": if len(publisher_id) > 0: form = PrivateMessageForm(request.POST) else: form = AdvertiserPrivateMessageForm(request.POST,org=request.organization) if form.is_valid(): if not publisher_id: publisher_id = [ form.cleaned_data['receiver'], ] for p_id in publisher_id: try: publisher = Organization.objects.get(id=p_id) PrivateMessage.objects.create(subject=form.cleaned_data['subject'], date_sent=datetime.datetime.now(), message=form.cleaned_data['message'], sender=request.organization, receiver=publisher, is_active=True, sender_status=MsgStatus(pk=1),receiver_status=MsgStatus(pk=1)) except Organization.DoesNotExist: pass referer = request.META.get('HTTP_REFERER', None) if referer == None: return HttpResponseRedirect("/advertiser/messages/") else: return HttpResponseRedirect(referer) else: d = { } if 'rid' in request.GET: try: rid = int(request.GET.get('rid', 0)) except ValueError: rid = 0 if rid > 0: try: recip = Organization.objects.get(id=rid) d['receiver'] = recip.name publisher_id = [rid] except Organizaion.DoesNotExist: pass if id: try: m = PrivateMessage.objects.get(id=id, receiver=request.organization) d['subject'] = 'Re: %s' % m.subject d['receiver'] = m.sender.name d['message'] = "On %s, %s wrote:\n%s" % (m.date_sent, m.sender.name, m.message, ) except PrivateMessage.DoesNotExist: raise Http404 if d.get('receiver'): form = PrivateMessageForm(initial=d) else: composeTo = request.GET.get("compose_to", None) form = AdvertiserPrivateMessageForm(org=request.organization,initial=d) # This is used to load the compose form within the 2nd level of lightboxes..ie, Lightbox loading a lightbox. if 'secondtier' in request.GET: secondTier = request.GET.get('secondtier') else: secondTier = 0 # Folder totals for sidebar inbox = PrivateMessage.objects.filter(receiver=request.organization.id, receiver_status=1).order_by('-date_sent') sent = PrivateMessage.objects.filter(sender=request.organization.id, sender_status=1).order_by('-date_sent') trash = PrivateMessage.objects.filter(Q(sender=request.organization.id, sender_status=3) | Q(receiver=request.organization.id, receiver_status=3)).order_by('-date_sent') return AQ_render_to_response(request, 'advertiser/messages/compose.html', { 'form' : form, 'inbox' : inbox, 'trash' : trash, 'sent' : sent, 'publisher_id' : publisher_id, 'composeTo' : composeTo, 'secondTier' : secondTier, }, context_instance=RequestContext(request))
def publisher_messages_compose(request, id=None): ''' View to Compose a PrivateMessage. This view can be passed multiple recipients through the GET variable "r_id" ''' from atrinsic.base.models import Organization, Organization_Status, PrivateMessage, PublisherRelationship, MsgStatus from forms import PrivateMessageForm, PublisherPrivateMessageForm, StatusUpdateForm from django.db.models import Q from django.core.mail import EmailMultiAlternatives composeTo = None if request.POST.get('MessageOrStatus', 'Msg') == 'Status': form = StatusUpdateForm(request.POST) if form.is_valid(): Organization_Status.objects.create(message=form.cleaned_data['message'], organization=request.organization) return HttpResponseRedirect('/publisher/messages/') if id != None: advertiser_id = [PrivateMessage.objects.get(id=id).sender.id] else: advertiser_id = request.REQUEST.getlist('advertiser_id') else: if id != None: advertiser_id = [PrivateMessage.objects.get(id=id).sender.id] else: advertiser_id = request.REQUEST.getlist('advertiser_id') if request.method == "POST": if len(advertiser_id) > 0: form = PrivateMessageForm(request.POST) else: form = PublisherPrivateMessageForm(request.POST,org=request.organization) if form.is_valid(): if not advertiser_id: advertiser_id = [ form.cleaned_data['receiver'], ] print "here" for p_id in advertiser_id: try: advertiser = Organization.objects.get(id=p_id) PrivateMessage.objects.create(subject=form.cleaned_data['subject'], date_sent=datetime.datetime.now(), message=form.cleaned_data['message'], sender=request.organization, receiver=advertiser, is_active=True, sender_status=MsgStatus(pk=1), receiver_status=MsgStatus(pk=1)) #For Kayak advertiser, we want to send a copy of that message. if int(advertiser_id[0]) == 711: destinations = ['*****@*****.**'] try: msg = EmailMultiAlternatives('MSG to Kayak.com: ' + form.cleaned_data['subject'],form.cleaned_data['message'],'*****@*****.**',destinations) msg.send() except: pass except Organization.DoesNotExist: pass referer = request.META.get('HTTP_REFERER', None) if referer == None: return HttpResponseRedirect("/publisher/messages/") else: return HttpResponseRedirect(referer) else: d = { } if 'rid' in request.GET: try: rid = int(request.GET.get('rid', 0)) except ValueError: rid = 0 if rid > 0: try: recip = Organization.objects.get(id=rid) d['receiver'] = recip.name advertiser_id = [rid] except Organizaion.DoesNotExist: pass if id: try: m = PrivateMessage.objects.get(id=id, receiver=request.organization) d['subject'] = 'Re: %s' % m.subject d['receiver'] = m.sender.name d['message'] = "On %s, %s wrote:\n%s" % (m.date_sent, m.sender.name, m.message, ) except PrivateMessage.DoesNotExist: raise Http404 if d.get('receiver'): form = PrivateMessageForm(initial=d) elif advertiser_id: d['receiver'] = 'Multiple Recipients' form = PrivateMessageForm(initial=d) else: composeTo = request.GET.get("compose_to", None) form = PublisherPrivateMessageForm(org=request.organization,initial=d) inbox = PrivateMessage.objects.filter(receiver=request.organization.id, receiver_status=1).order_by('-date_sent') sent = PrivateMessage.objects.filter(sender=request.organization.id, sender_status=1).order_by('-date_sent') trash = PrivateMessage.objects.filter(Q(sender=request.organization.id, sender_status=3) | Q(receiver=request.organization.id, receiver_status=3)).order_by('-date_sent') return AQ_render_to_response(request, 'publisher/messages/compose.html', { 'form' : form, 'inbox' : inbox, 'trash' : trash, 'sent' : sent, 'advertiser_id' : advertiser_id, 'composeTo' : composeTo, }, context_instance=RequestContext(request))