Ejemplo n.º 1
0
def newEvent(request, redirectURL='/admin/events/requests/'):
    if request.method == 'POST':
        form = EventFormAdmin(request.POST)
        if form.is_valid():
            # form passed validation, and objects in form.cleaned_data dict.
            fd = form.cleaned_data
            try:
                event = Event(
                    event_title=fd['event_title'],
                    event_date=fd['event_date'],
                    event_duration=fd['event_duration'],
                    event_audience=fd['event_audience'],
                    event_visitors=fd['event_visitors'],
                    event_component_vizwall=fd['event_component_vizwall'],
                    event_component_3dtv=fd['event_component_3dtv'],
                    event_component_omni=fd['event_component_omni'],
                    event_component_hd2=fd['event_component_hd2'],
                    event_component_smart=fd['event_component_smart'],
                    event_assistance=fd['event_assistance'],
                    event_contact_name=fd['event_contact_name'],
                    event_contact_dept=fd['event_contact_dept'],
                    event_contact_exec=fd['event_contact_exec'],
                    event_contact_phone=fd['event_contact_phone'],
                    event_contact_email=fd['event_contact_email'],
                    event_details=fd['event_details'],
                    event_is_published=fd['event_is_published'],
                    event_is_declined=fd['event_is_declined'])
                #event_assigned_proctors=fd['event_assigned_proctors'])
                # conflicts are checked upon form validation method so no checking here!
                event.save(
                )  # have to save the event before assigning the proctors in order for the manytomany relationship to be created.
                assignedProctors = event.assign_proctors_byID(fd['proctors'])
                event.save()  # save again to make the final call
                ps = event.get_assigned_proctors_can_email()
                proctors = [u.email for u in ps] if ps else []
                if proctors:
                    mail_send(proctors,
                              event,
                              'mail/proctor_new_assignment',
                              calendar=True)
                # don't send mail to schedulers! they already know!
                # send mail confirmation to requester
                recipients = [event.event_contact_email]
                mail_send(recipients,
                          event,
                          'mail/requester_confirm_request',
                          calendar=True)
            except:
                # Something bad happened, apologize and tell them to contact us.
                return render_to_response(
                    'events/customadmin/eventrequest.html', {'form': form},
                    context_instance=RequestContext(request))
            # eveything suceeded, lets redirect to pending events page
            return HttpResponseRedirect(redirectURL)
    else:
        # they need to fill the form out
        form = EventForm()
    return render_to_response('events/eventrequest.html', {'form': form},
                              context_instance=RequestContext(request))
Ejemplo n.º 2
0
def requestEvent(request):
    if request.method == 'POST':  # if form has been submitted...
        form = EventForm(request.POST)
        if form.is_valid():
            # form passed validation, and objects in form.cleaned_data dict.
            fd = form.cleaned_data
            try:
                event = Event(
                    event_title=fd['event_title'],
                    event_date=fd['event_date'],
                    event_duration=fd['event_duration'],
                    event_audience=fd['event_audience'],
                    event_visitors=fd['event_visitors'],
                    event_component_vizwall=fd['event_component_vizwall'],
                    event_component_3dtv=fd['event_component_3dtv'],
                    event_component_omni=fd['event_component_omni'],
                    event_component_hd2=fd['event_component_hd2'],
                    event_component_smart=fd['event_component_smart'],
                    event_assistance=fd['event_assistance'],
                    event_contact_name=fd['event_contact_name'],
                    event_contact_dept=fd['event_contact_dept'],
                    event_contact_exec=fd['event_contact_exec'],
                    event_contact_phone=fd['event_contact_phone'],
                    event_contact_email=fd['event_contact_email'],
                    event_details=fd['event_details'])
                # conflicts are checked upon form validation method so no checking here!
                event.save()
                # send mail to schedulers about new event
                schedulers = [
                    u.user.email for u in UserProfile.objects.all().filter(
                        is_scheduler=True, force_no_emails=False)
                ]
                mail_send(schedulers, event, 'mail/sched_new_request')
                # send mail confirmation to requester
                recipients = [event.event_contact_email]
                mail_send(recipients, event, 'mail/requester_new_request')
            except:
                # Something bad happened, apologize and tell them to contact us.
                return render_to_response(
                    'events/eventrequest.html', {'form': form},
                    context_instance=RequestContext(request))
            # eveything suceeded, lets redirect for confirmation!
            return HttpResponseRedirect('/events/request/confirm/')
    else:
        # they need to fill the form out
        form = EventForm()
    return render_to_response('events/eventrequest.html', {'form': form},
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
 def handle_noargs(self, **options):
     while True:
         title = raw_input("Title: ")
         edate = raw_input("Event Date: ")
         if not edate:
             edate = datetime.datetime.now()
         else:
             edate = datetime.datetime.strptime(edate, "%m/%d/%Y %H:%M")
         duration = raw_input("Duration in minutes: ")
         if not duration:
             duration = 60
         else:
             try:
                 duration = int(duration)
             except:
                 duration = 60
         audience = raw_input("Description of Audience: ")
         c_name = raw_input("Contact Name: ")
         c_phone = raw_input("Contact Phone: ")
         if not c_phone:
             c_phone = "210-458-6479"
         c_dept = raw_input("Contact Dept: ")
         if not c_dept:
             c_dept = "Mechanical Engineering"
         c_email = raw_input("Contact Email: ")
         if not c_email:
             c_email = "*****@*****.**"
         details = raw_input("Event Details: ")
         saveit = raw_input("Save it? [y/N]: ")
         if not saveit.lower() == "y":
             self.stdout.write("== Not Saved! ==\n\n")
         else:
             e = Event(
                 event_title=title,
                 event_duration=duration,
                 event_date=edate,
                 event_audience=audience,
                 event_visitors=20,
                 event_component_vizwall=True,
                 event_component_3dtv=True,
                 event_component_omni=True,
                 event_component_hd2=True,
                 event_component_smart=True,
                 event_assistance=True,
                 event_contact_name=c_name,
                 event_contact_dept=c_dept,
                 event_contact_exec=7,
                 event_contact_phone=c_phone,
                 event_contact_email=c_email,
                 event_details=details,
                 event_is_published=True,
             )
             e.pub_date = edate
             e.req_date = edate
             e.last_modified = edate
             e.save()
             self.stdout.write("=======Event saved========\n\n")
         another = raw_input("Create a new one? [y/N]: ")
         if not another.lower() == "y":
             break
Ejemplo n.º 4
0
def requestEvent(request):
  if request.method == 'POST': # if form has been submitted...
   form = EventForm(request.POST)
   if form.is_valid():
    # form passed validation, and objects in form.cleaned_data dict.
    fd = form.cleaned_data
    try:
      event = Event(event_title=fd['event_title'], event_date=fd['event_date'],
                event_duration=fd['event_duration'],
                event_audience=fd['event_audience'],
                event_visitors=fd['event_visitors'],
                event_component_vizwall=fd['event_component_vizwall'],
                event_component_3dtv=fd['event_component_3dtv'],
                event_component_omni=fd['event_component_omni'],
                event_component_hd2=fd['event_component_hd2'],
                event_component_smart=fd['event_component_smart'],
                event_assistance=fd['event_assistance'],
                event_contact_name=fd['event_contact_name'],
                event_contact_dept=fd['event_contact_dept'],
                event_contact_exec=fd['event_contact_exec'],
                event_contact_phone=fd['event_contact_phone'],
                event_contact_email=fd['event_contact_email'],
                event_details=fd['event_details'])
      # conflicts are checked upon form validation method so no checking here!
      event.save()
      # send mail to schedulers about new event
      schedulers = [u.user.email for u in UserProfile.objects.all().filter(is_scheduler=True,force_no_emails=False)]
      mail_send(schedulers, event, 'mail/sched_new_request')
      # send mail confirmation to requester
      recipients = [event.event_contact_email]
      mail_send(recipients, event, 'mail/requester_new_request')
    except:
      # Something bad happened, apologize and tell them to contact us.
      return render_to_response('events/eventrequest.html', {'form': form}, context_instance=RequestContext(request))
    # eveything suceeded, lets redirect for confirmation!
    return HttpResponseRedirect('/events/request/confirm/')
  else:
    # they need to fill the form out
    form = EventForm()
  return render_to_response('events/eventrequest.html', {'form': form}, context_instance=RequestContext(request))
Ejemplo n.º 5
0
def newEvent(request, redirectURL='/admin/events/requests/'):
  if request.method == 'POST':
    form = EventFormAdmin(request.POST)
    if form.is_valid():
      # form passed validation, and objects in form.cleaned_data dict.
      fd = form.cleaned_data
      try:
        event = Event(event_title=fd['event_title'], event_date=fd['event_date'],
                  event_duration=fd['event_duration'],
                  event_audience=fd['event_audience'],
                  event_visitors=fd['event_visitors'],
                  event_component_vizwall=fd['event_component_vizwall'],
                  event_component_3dtv=fd['event_component_3dtv'],
                  event_component_omni=fd['event_component_omni'],
                  event_component_hd2=fd['event_component_hd2'],
                  event_component_smart=fd['event_component_smart'],
                  event_assistance=fd['event_assistance'],
                  event_contact_name=fd['event_contact_name'],
                  event_contact_dept=fd['event_contact_dept'],
                  event_contact_exec=fd['event_contact_exec'],
                  event_contact_phone=fd['event_contact_phone'],
                  event_contact_email=fd['event_contact_email'],
                  event_details=fd['event_details'],
                  event_is_published=fd['event_is_published'],
                  event_is_declined=fd['event_is_declined'])
                  #event_assigned_proctors=fd['event_assigned_proctors'])
        # conflicts are checked upon form validation method so no checking here!
        event.save() # have to save the event before assigning the proctors in order for the manytomany relationship to be created.
        assignedProctors = event.assign_proctors_byID(fd['proctors'])
        event.save() # save again to make the final call
        ps = event.get_assigned_proctors_can_email()
        proctors = [u.email for u in ps] if ps else []
        if proctors: mail_send(proctors, event, 'mail/proctor_new_assignment', calendar=True)
        # don't send mail to schedulers! they already know!
        # send mail confirmation to requester
        recipients = [event.event_contact_email]
        mail_send(recipients, event, 'mail/requester_confirm_request', calendar=True)
      except:
        # Something bad happened, apologize and tell them to contact us.
        return render_to_response('events/customadmin/eventrequest.html', {'form': form}, context_instance=RequestContext(request))
      # eveything suceeded, lets redirect to pending events page
      return HttpResponseRedirect(redirectURL)
  else:
    # they need to fill the form out
    form = EventForm()
  return render_to_response('events/eventrequest.html', {'form': form}, context_instance=RequestContext(request))
Ejemplo n.º 6
0
 def handle_noargs(self, **options):
   while True:
     title = raw_input('Title: ')
     edate = raw_input('Event Date: ')
     if not edate:
       edate = datetime.datetime.now()
     else:
       edate = datetime.datetime.strptime(edate, '%m/%d/%Y %H:%M')
     duration = raw_input('Duration in minutes: ')
     if not duration:
       duration = 60
     else:
       try:
         duration = int(duration)
       except:
         duration = 60
     audience = raw_input('Description of Audience: ')
     c_name = raw_input('Contact Name: ')
     c_phone = raw_input('Contact Phone: ')
     if not c_phone: c_phone = '210-458-6479'
     c_dept = raw_input('Contact Dept: ')
     if not c_dept: c_dept = 'Mechanical Engineering'
     c_email = raw_input('Contact Email: ')
     if not c_email: c_email = '*****@*****.**'
     details = raw_input('Event Details: ')
     saveit = raw_input('Save it? [y/N]: ')
     if not saveit.lower() == 'y':
       self.stdout.write("== Not Saved! ==\n\n")
     else:
       e = Event(event_title=title, event_duration=duration, event_date=edate, event_audience=audience, event_visitors=20, event_component_vizwall=True, event_component_3dtv=True, event_component_omni=True, event_component_hd2=True, event_component_smart=True, event_assistance=True, event_contact_name=c_name, event_contact_dept=c_dept, event_contact_exec=7, event_contact_phone=c_phone, event_contact_email=c_email, event_details=details, event_is_published=True)
       e.pub_date = edate
       e.req_date = edate
       e.last_modified = edate
       e.save()
       self.stdout.write("=======Event saved========\n\n")
     another = raw_input('Create a new one? [y/N]: ')
     if not another.lower() == 'y':
       break