def signup(request, src): if not src: text = "" for source in SIGNUP_SOURCES: text += '<p><a href="./%s">%s</a></p>' % (source, source) context = { "body": format_html(text), } return render_page(request, context) else: if request.method == "GET": context = { "body": render_to_string('rush/signup.html', {"title": src}, request=request), "post_body_script": render_to_string('rush/signup.js') } return render_page(request, context) elif request.method == "POST": data = request.POST rush = RushProfile(first_name=data.get('rushFirstName'), last_name=data.get('rushLastName'), email=data.get('rushEmail').replace( "@bu.edu", ""), semester=SEMESTER, phone_number=data.get('rushPhone'), grade=data.get('rushGrade'), channel=src, major_schools=data.getlist('rushSchool[]'), majors=data.get('rushMajors'), minors=data.get('rushMinors')) success_error_msg = "%s has successfully been signed up" % ( data.get('rushFirstName'), ) try: rush.save() except Exception: success_error_msg = "An error has occurred. Please try again." body_context = { 'title': src, 'success_error_msg': success_error_msg } context = { "body": render_to_string('rush/signup.html', body_context, request=request), "post_body_script": render_to_string('rush/signup.js') } return render_page(request, context)
def data(request): if request.POST.get("password") != DATA_PASSWORD: body_context = { "incorrect_password": (request.POST.get("password") != None) } context = { "body": render_to_string('rush/data.html', body_context, request=request) } return render_page(request, context) rushes = RushProfile.objects.all() context = {"body": render_to_string('rush/data.html', request=request)} return render_page(request, context)
def export(request): if request.POST.get("password") != EXPORT_PASSWORD: body_context = { "incorrect_password": (request.POST.get("password") != None) } context = { "body": render_to_string('rush/data.html', body_context, request=request) } return render_page(request, context) response = HttpResponse(content_type='text/csv') response[ 'Content-Disposition'] = 'attachment; filename="rushes_%s.csv"' % SEMESTER writer = csv.writer(response) writer.writerow([x[0] for x in fields]) rushes = RushProfile.objects.filter(semester=SEMESTER).values_list( *[x[1] for x in fields]) for rush in rushes: writer.writerow([str(x) for x in rush]) return response
def index(request): body = render_to_string('nccg/index.html') context = { 'body': body, } return render_page(request, context)
def alumni(request): alumni_brothers = Brother.objects.filter(status=Brother.ALUMNI) years = alumni_brothers.aggregate(Max('year'), Min('year')) min_year = int(years['year__min']) max_year = int(years['year__max']) alumni = dict() for year in range(min_year, max_year + 1): brothers = alumni_brothers.filter(year=str(year)) alumni[year] = brothers body_context = { 'active_brothers': alumni, 'min_year': min_year, 'max_year': max_year, 'years': range(min_year, max_year + 1), } js_context = { 'min_year': min_year, 'max_year': max_year, 'total_alumni': alumni_brothers.count(), } print(js_context) context = { "body": render_to_string("brothers/alumni.html", body_context), "post_body_script": render_to_string("brothers/alumni.js", js_context) } return render_page(request, context)
def index(request): body = render_to_string('sfg/index.html') context = { 'body': body, 'post_body_script': render_to_string('sfg/index.js'), } return render_page(request, context)
def index(request): events = RushEvent.objects.filter(is_open_rush=True).order_by('start_time') building_ids = events.values_list('building', flat=True) buildings = RushEventLocation.objects.filter( pk__in=building_ids).distinct() markers = {} for building in buildings: markers[building] = {} # Organize events by buildings for event in events: building = markers[event.building] room = event.room_number if event.room_long_name: room += " (%s)" % event.room_long_name if room in building.keys(): building[room] += ', ' + event.name else: building[room] = event.name # Turn building rooms and events into string for building in buildings: window_text = [] for room in markers[building].keys(): window_text.append("<strong>%s</strong>" % markers[building][room]) window_text.append(room) markers[building] = "<br>".join(window_text) center = {} if len(events): center = { 'lat': sum([building.lat for building in buildings]) / buildings.count(), 'lng': sum([building.lng for building in buildings]) / buildings.count(), } else: center = {'lat': 42.350500, 'lng': -71.105399} body_context = { "markers": markers, "center": center, "events": events, "from_facebook": 'HTTP_REFERER' in request.META.keys() and 'facebook' in request.META['HTTP_REFERER'] } context = { "head": render_to_string("rush/index_head.html"), "body": render_to_string("rush/index.html", body_context), } return render_page(request, context)
def partners(request): body_context = { 'partners': NCCGPartner.objects.all(), } context = { "body": render_to_string("nccg/partners.html", body_context), } return render_page(request, context)
def index(request): body_context = { 'articles': BlogArticle.objects.all()[:2], } context = { "body": render_to_string("eye2eye/index.html", body_context), } return render_page(request, context)
def clients(request): body_context = { 'clients': NCCGClient.objects.all(), } context = { "body": render_to_string("nccg/clients.html", body_context), } return render_page(request, context)
def advisors(request): body_context = { 'advisors': NCCGAdvisor.objects.all(), } context = { "body": render_to_string("nccg/advisors.html", body_context), } return render_page(request, context)
def blog(request): body_context = { 'articles': BlogArticle.objects.all()[:10], } context = { "body": render_to_string("eye2eye/blog.html", body_context), # "post_body_script": render_to_string("eye2eye/board.js") } return render_page(request, context)
def board(request): body_context = { 'members': Eye2EyeMember.objects.all(), } context = { "body": render_to_string("eye2eye/board.html", body_context), "post_body_script": render_to_string("eye2eye/board.js") } return render_page(request, context)
def team(request): body_context = { 'members': SFGMember.objects.all(), } context = { "body": render_to_string("sfg/team.html", body_context), "post_body_script": render_to_string("sfg/team.js") } return render_page(request, context)
def index(request): script_context = {"rushes": RushProfile.objects.filter(semester=SEMESTER)} context = { "body": render_to_string("rush/application.html", {"questions": QUESTIONS}, request=request), "head": render_to_string("rush/application_head.html"), "post_body_script": render_to_string("rush/application.js", script_context), } return render_page(request, context)
def index(request): brothers = Brother.objects.filter( status=Brother.ACTIVE).order_by("last_name") classes = set(brothers.values_list('class_name', flat=True)\ .exclude(class_name = "Transfer")) sorted_classes = sorted(classes, key=key_for_class) + ["Transfer"] body_context = { 'eboard': EBoardMember.objects.all(), 'brothers': brothers, 'active_classes': sorted_classes } context = { "body": render_to_string("brothers/index.html", body_context), "post_body_script": render_to_string("brothers/index.js") } return render_page(request, context)
def view(request, email): rush = get_object_or_404(RushProfile, email=email) events = RushEvent.objects.filter(is_open_rush=True) answers = rush.application.application_answers questions = copy(QUESTIONS) for key in questions: value = questions[key] for i, question in enumerate(value): question.rush_answer = answers[key + "_" + str(i + 1)] body_context = { "rush": rush, "events": events, "questions": questions, } context = { "body": render_to_string("rush/view.html", body_context), } return render_page(request, context)
def submit(request): success = False failure_data = None try: application_answers = {} post_data = request.POST for key in post_data: if "short_answer_" in key or "feedback_" in key or "logic_" in key: application_answers[key] = post_data.get(key) email = post_data.get('rushEmail').replace("@bu.edu", "") rush = None matchingRushes = RushProfile.objects.filter(email=email) if matchingRushes.count() > 0: rush = matchingRushes[0] rush.channel = 'application' else: rush = RushProfile() rush.first_name = post_data.get('rushFirstName')[:20] rush.last_name = post_data.get('rushLastName')[:20] rush.email = email rush.semester = SEMESTER rush.phone_number = post_data.get('rushPhone')[:11] rush.grade = post_data.get('rushGrade') rush.major_schools = post_data.getlist('rushSchool[]') rush.majors = post_data.get('rushMajors')[:100] rush.minors = post_data.get('rushMinors')[:100] rush.submitted_application = True application = RushApplication( profile=rush, address=post_data.get('rushAddress')[:100], gpa=post_data.get('rushGPA')[:5], application_answers=application_answers, picture=request.FILES['rushPic'], resume=request.FILES['rushResume'], ) application.save() rush.save() email = EmailMessage( "Alpha Kappa Psi - Rush Application Submission", "Dear " + post_data['rushFirstName'] + ",\r\n\r\nThank you for your application! We look forward to reviewing your application and will contact you with further details on your candidacy by Sunday night. Below is a copy of your application for your own record.\r\n\r\n------------------------------\r\n\r\n" + "Email: " + post_data.get("rushEmail") + "@bu.edu\r\n" + "First Name: " + post_data.get("rushFirstName") + "\r\n" + "Last Name: " + post_data.get("rushLastName") + "\r\n" + "Grade: " + post_data.get("rushGrade") + "\r\n" + "School: " + str(post_data.getlist("rushSchool[]")) + "\r\n" + "Majors: " + post_data.get("rushMajors") + "\r\n" + "Minors: " + post_data.get("rushMinors") + "\r\n" + "Phone: " + post_data.get("rushPhone") + "\r\n" + "Address: " + post_data.get("rushAddress") + "\r\n" + "GPA: " + post_data.get("rushGPA") + "\r\n" + "\r\n" + "Answers: " + str(application_answers) + "\r\n" + "\r\n", 'Alpha Kappa Psi Nu Chapter <*****@*****.**>', to=[email + "@bu.edu"], reply_to=["*****@*****.**"], ) email.send() success = True except Exception as e: traceback.print_exc() failure_data = str(request.POST) + """ %s """ % str(e) body_context = {"success": success, "failure_data": failure_data} context = { "body": render_to_string("rush/submit.html", body_context, request=request), } return render_page(request, context)
def event(request, name): if not name: text = "" events = RushEvent.objects.all().values_list('name', flat=True) for name in events: text += '<p><a href="./%s">%s</a></p>' % (name, name) context = { "body": format_html(text), } return render_page(request, context) else: rushes = RushProfile.objects.filter(semester=SEMESTER) if request.method == "GET": context = { "body": render_to_string('rush/events.html', {"title": name}, request=request), "post_body_script": render_to_string('rush/events.js', {"rushes": rushes}) } return render_page(request, context) elif request.method == "POST": data = request.POST email = data.get('rushEmail').replace("@bu.edu", "") rush = None matchingRushes = RushProfile.objects.filter(email=email) if matchingRushes.count() > 0: rush = matchingRushes[0] rush.channel = 'event' else: rush = RushProfile() rush.first_name = data.get('rushFirstName') rush.last_name = data.get('rushLastName') rush.email = email rush.semester = SEMESTER rush.phone_number = data.get('rushPhone') rush.grade = data.get('rushGrade') rush.major_schools = data.getlist('rushSchool[]') rush.majors = data.get('rushMajors') rush.minors = data.get('rushMinors') if not name in rush.events_attended: rush.events_attended.append(name) rush.save() success_error_msg = "%s %s - Saved Successfully" % ( data.get('rushFirstName'), data.get('rushLastName')) try: rush.save() except Exception: success_error_msg = "An error has occurred. Please try again." body_context = { 'title': name, 'success_error_msg': success_error_msg } context = { "body": render_to_string('rush/events.html', body_context, request=request), "post_body_script": render_to_string('rush/events.js', {"rushes": rushes}) } return render_page(request, context)