Пример #1
0
def bike_request(request):
    data = request.POST
    student = Student.objects.get(penncard=data.get("penncard"))
    approx_height = data.get("approx_height")
    bike_type = data.get("bike_type")
    available_time = data.get("available_time")

    current_payment = student.current_payment
    plan_info = ""
    if (current_payment):
        plan_info = "{}, expiring on {}".format(current_payment.plan.name, current_payment.end_date.strftime("%m/%d/%y"))
    else:
        plan_info = "You currently don't have a plan. Please purchase a plan when you collect your bike."
    plan_info += """
Dear {},

New PennCycle Bike request with the following info:

Approximate height: {}
Bike type: {}
Available times to collect bike from Quaker Corner: {}
Current Plan: {}
    """.format(student.name, approx_height, bike_type, available_time, plan_info)
    email_managers("New PennCycle Bike request", plan_info)

    request_bike_email(bike_type, approx_height, available_time, student)
    return HttpResponse('success')
Пример #2
0
	def handle_noargs(self, **options):
		today = timezone.now().date()
		one_month_from_now = today + timezone.timedelta(days=30)
		payments = Payment.objects.filter(end_date=today, renew=True)
		message = "The following have had their plans renewed, but have not been charged: \n"
		for payment in payments:
			old_end_date = payment.end_date
			payment.end_date = one_month_from_now
			payment.save()
			renewed_email(payment, old_end_date)
			message += "{student} with last two {last_two}: {plan}\n".format(
				student=payment.student, last_two=payment.student.last_two,
				plan=payment.plan
			)
		if payments:
			 email_managers(
				"{} renewals: {} total".format(today, len(payments)),
				message
			)
Пример #3
0
def group_ride_request(request):
    data = request.POST
    student_name = data.get("student_name")
    organization = data.get("organization")
    position_in_organization = data.get("position_in_organization")
    email = data.get("email")
    destination_of_ride = data.get("destination_of_ride")
    approximate_duration = data.get("approximate_duration")
    total_bikes = data.get("total_bikes")
    require_pc_representative = data.get("require_pc_representative")
    subject = "Group Ride Request"
    
    # message to bike manager
    body = """
    New Group Ride Request with the following information:
    
        Student Name: {}
        Organization: {}
        Position in Organization: {}
        Email: {}
        Destination of Ride: {}
        Approximate Duration: {}
        Total number of Bikes: {}
        Does the group require a PennCycle represntative? {}

        """.format(student_name, organization, position_in_organization, email, destination_of_ride, approximate_duration, total_bikes, require_pc_representative)
    email_managers(subject, body)
    
    # message to user
    body = """
    Your group ride request to {} for {} bikes is under process. PennCycle will get back to you at the earliest.

    Thanks for using PennCycle.

    Have a question, concern, or suggestion? Email us at [email protected].

    Happy Cycling!

    The PennCycle Team.
    """.format(destination_of_ride, total_bikes)
    email_user(subject, body, email)
    return HttpResponse("success")
Пример #4
0
    def form_valid(self, form):
        student = form.save()

        location = student.living_location

        if location in ["Ware", "Fisher"]:
            basic_plan = Plan.objects.get(name="Basic Plan")
            free_payment = Payment(
                student=student,
                amount=0,
                plan=basic_plan,
                payment_date=timezone.datetime.now(),
                end_date=timezone.datetime(year=2014, month=5, day=2),
                satisfied=True,
                payment_type="free",
            )
            free_payment.save()
            extra_info = ("Since you are a resident of {}, "
                "you automatically get a free basic plan which lasts "
                "until the end of the school year.").format(location)
            messages.info(self.request, extra_info)

        messages.info(self.request,
            "Your pin is {}. "
            "You will need it to log on in the future.".format(student.pin))
        
        # plan = Plan.objects.get(student)
        body = """
            {} has signed up for a PennCycle plan.
            You can reach him at {}.
        """.format(student.name, student.email)
        email_managers("New Signup", body)

        welcome_email(student)
        self.request.session['penncard'] = student.penncard
        return HttpResponseRedirect('/safety-overview/')