Example #1
0
def view(request, slug):
	committee = get_object_or_404(Committee, slug=slug)
	# If the user is a member of the dais, show a link to the uploads page
	is_dais = get_committee_from_email(request.user.username) == committee

	show_manage_link = committee.allow_manager(request.user)
	# If background guide is uploaded
	bgset = committee.committeebackgroundguide_set.all()
	bg_uploaded = False
	if bgset.count():
		bg_uploaded = True


	data = {
		'page': {
			'long_name': committee.name,
		},
		'is_dais': is_dais,
		'committee': committee,
		'bg_uploaded': bg_uploaded,
		'bgset': bgset,
		'show_manage_link': show_manage_link,
	}

	return render(request, 'committee.html', data)
Example #2
0
def survey_result(request):
	# If it's a dais member, redirect to that committee's position paper listing
	if request.user.username.endswith('@ssuns.org'):
		dais_committee = get_committee_from_email(request.user.username)
		if dais_committee:
			return redirect(dais_committee)

	form = None
	school = None
	message = None

	if request.user.registeredschool_set.count():
		# There should only be one anyway (see comment in models.py)
		school = request.user.registeredschool_set.filter(is_approved=True)[0]
		
		survey = DelegateSurvey.objects.filter(school=school)
		if survey.count() == 0:
			message = "Sorry, none of your delegate has fill out the survey yet!"

		data = {
			'survey_result': survey,
			'message': message,
			'survey_answer': SURVEYANSWER
		}
	return render(request, "survey_result.html", data)
Example #3
0
def serve_papers(request, file_name):
    # Check if user is an admin/mod OR if the user uploaded the file OR dais
    is_authorised = False
    full_path = os.path.join(position_paper_upload_path, file_name)

    if request.user.is_staff:
        is_authorised = True
    elif request.user.username.endswith('@ssuns.org'):
        # Check the dais
        committee = get_committee_from_email(request.user.username)
        if committee and committee.committeeassignment_set.filter(
                position_paper=full_path):
            is_authorised = True
    else:
        user_schools = request.user.registeredschool_set.filter(
            is_approved=True)
        if user_schools.count() == 1:
            school = user_schools[0]
            if school.committeeassignment_set.filter(position_paper=full_path):
                is_authorised = True

    if is_authorised:
        return serve(
            request, file_name,
            os.path.join(settings.MEDIA_ROOT, position_paper_upload_path))
    else:
        raise PermissionDenied
Example #4
0
def view(request, slug):
	committee = get_object_or_404(Committee, slug=slug)
	# If the user is a member of the dais, show a link to the uploads page
	is_dais = get_committee_from_email(request.user.username) == committee

	data = {
		'page': {
			'long_name': committee.name,
		},
		'is_dais': is_dais,
		'committee': committee,
		'dais_template': 'dais_photos/%s.html' % committee.slug,
		'DAIS_PHOTO_URL': '%simg/dais/%s/' % (settings.STATIC_URL, committee.slug),
	}

	return render(request, 'committee.html', data)
Example #5
0
def list_papers(request, slug):
	committee = get_object_or_404(Committee, slug=slug)

	# Only the dais for this committee and other admins can access this
	if (get_committee_from_email(request.user.username) == committee
		or request.user.is_staff):
		data = {
			'page': {
				'long_name': 'Position papers for %s' % committee.name,
			},
			'committee': committee,
			'assignments': committee.committeeassignment_set.order_by('-position_paper'),
		}

		return render(request, 'list_papers.html', data)
	else:
		raise Http404
Example #6
0
def list_papers(request, slug):
    committee = get_object_or_404(Committee, slug=slug)

    # Only the dais for this committee and other admins can access this
    if (get_committee_from_email(request.user.username) == committee
            or request.user.is_staff):
        data = {
            'page': {
                'long_name': 'Position papers for %s' % committee.name,
            },
            'committee':
            committee,
            'assignments':
            committee.committeeassignment_set.order_by('-position_paper'),
        }

        return render(request, 'list_papers.html', data)
    else:
        raise Http404
Example #7
0
def view(request, slug):
    committee = get_object_or_404(Committee, slug=slug)
    if not committee.is_visible:
        raise Http404

    # If the user is a member of the dais, show a link to the uploads page
    is_dais = get_committee_from_email(request.user.username) == committee

    data = {
        'page': {
            'long_name': committee.name,
        },
        'is_dais': is_dais,
        'committee': committee,
        'dais_template': 'dais_photos/%s.html' % committee.slug,
        'DAIS_PHOTO_URL':
        '%simg/dais/%s/' % (settings.STATIC_URL, committee.slug),
    }

    return render(request, 'committee.html', data)
Example #8
0
def serve_papers(request, file_name):
    # Check if user is an admin/mod OR if the user uploaded the file OR dais
    is_authorised = False
    full_path = os.path.join(position_paper_upload_path, file_name)

    if request.user.is_staff:
        is_authorised = True
    elif request.user.username.endswith('@mcmun.org'):
        # Check the dais
        committee = get_committee_from_email(request.user.username)
        if committee and committee.committeeassignment_set.filter(position_paper=full_path):
            is_authorised = True
    else:
        user_schools = request.user.registeredschool_set.filter(is_approved=True)
        if user_schools.count() == 1:
            school = user_schools[0]
            if school.committeeassignment_set.filter(position_paper=full_path):
                is_authorised = True

    if is_authorised:
        return serve(request, file_name, os.path.join(settings.MEDIA_ROOT, position_paper_upload_path))
    else:
        raise PermissionDenied
Example #9
0
def view(request, slug):
    committee = get_object_or_404(Committee, slug=slug)
    # If the user is a member of the dais, show a link to the uploads page
    is_dais = get_committee_from_email(request.user.username) == committee

    show_manage_link = committee.allow_manager(request.user)
    # If background guide is uploaded
    bgset = committee.committeebackgroundguide_set.all()
    bg_uploaded = False
    if bgset.count():
        bg_uploaded = True

    data = {
        'page': {
            'long_name': committee.name,
        },
        'is_dais': is_dais,
        'committee': committee,
        'bg_uploaded': bg_uploaded,
        'bgset': bgset,
        'show_manage_link': show_manage_link,
    }

    return render(request, 'committee.html', data)
Example #10
0
def view(request, slug):
	committee = get_object_or_404(Committee, slug=slug)
	# If the user is a member of the dais, show a link to the uploads page
	is_dais = get_committee_from_email(request.user.username) == committee
	# If background guide is uploaded
	bgset = committee.committeebackgroundguide_set.all()
	bg_uploaded = False
	if bgset.count():
		bg_uploaded = True


	data = {
		'page': {
			'long_name': committee.name,
		},
		'is_dais': is_dais,
		'committee': committee,
		'bg_uploaded': bg_uploaded,
		'bgset': bgset,
		'dais_template': 'dais_photos/%s.html' % committee.slug,
		'DAIS_PHOTO_URL': '%simg/dais/%s/' % (settings.STATIC_URL, committee.slug),
	}

	return render(request, 'committee.html', data)
Example #11
0
def dashboard(request):
    # If it's a dais member, redirect to that committee's position paper listing
    if request.user.username.endswith('@mcmun.org'):
        dais_committee = get_committee_from_email(request.user.username)
        if dais_committee:
            return redirect(dais_committee)

    form = None
    school = None
    event_form = None
    committees_form = None

    if request.user.registeredschool_set.count():
        # There should only be one anyway (see comment in models.py)
        school = request.user.registeredschool_set.filter(is_approved=True)[0]

        # Only show it if the user has not entered values yet
        if school.num_pub_crawl == 0 and school.num_non_alcohol == 0:
            event_form = EventForm(instance=school)

        # Iff there is no scholarship application with this school, show the form
        if ScholarshipApp.objects.filter(school=school).count() == 0:
            if request.method == 'POST':
                form = ScholarshipForm(request.POST)

                if form.is_valid():
                    scholarship_app = form.save(commit=False)
                    scholarship_app.school = school
                    scholarship_app.save()

                    # Show the "thank you for your application" message
                    form = None
            else:
                form = ScholarshipForm()

        # If we haven't passed the committee prefs deadline, show the form
        prefs_deadline = datetime.datetime(2012, 11, 19)  # Nov 18 midnight
        if datetime.datetime.now() < prefs_deadline:
            committees_form = CommitteePrefsForm(instance=school)
    elif request.user.is_staff:
        # Show a random school (the first one registered)
        # Admins can see the dashboard, but can't fill out any forms
        school = RegisteredSchool.objects.get(pk=1)

    com_assignments = school.committeeassignment_set.all()
    formset = CommitteeAssignmentFormSet(queryset=com_assignments,
                                         prefix='lol')
    del_forms = []
    for com_assignment in com_assignments:
        del_forms.append(
            DelegateAssignmentFormset(
                queryset=com_assignment.delegateassignment_set.all(),
                prefix='%d' % com_assignment.id))

    data = {
        'management_forms':
        [formset.management_form] + [f.management_form for f in del_forms],
        'formset':
        zip(formset, del_forms),
        'unfilled_assignments':
        school.has_unfilled_assignments(),
        'school':
        school,
        'event_form':
        event_form,
        'committees_form':
        committees_form,
        'form':
        form,
        # Needed to show the title (as base.html expects the CMS view)
        'page': {
            'long_name': 'Your dashboard',
        },
    }

    return render(request, "dashboard.html", data)
Example #12
0
def dashboard(request):
	# If it's a dais member, redirect to that committee's position paper listing
	if request.user.username.endswith('@ssuns.org'):
		dais_committee = get_committee_from_email(request.user.username)
		if dais_committee:
			return redirect(dais_committee)

	form = None
	school = None
	scholarshipfile = None
	addDelegateList = None
	additional_pay = None

	if request.user.registeredschool_set.count():
		# There should only be one anyway (see comment in models.py)
		school = request.user.registeredschool_set.filter(is_approved=True)[0]
		
		additional_pay = AddDelegates.objects.filter(school=school)

		if ScholarshipSchoolApp.objects.filter(school=school).count() == 0:
			# show scholarship application form 
			if request.method == 'POST':
				form = ScholarshipSchoolForm(request.POST, request.FILES)

				if form.is_valid():
					scholarship_app = form.save(commit=False)
					scholarship_app.school = school
					scholarship_app.save()

					form = None
					scholarshipfile = ScholarshipSchoolApp.objects.get(school=school)
			else:
				form = ScholarshipSchoolForm()
		else:
			scholarshipfile = ScholarshipSchoolApp.objects.get(school=school)

		# If we haven't passed the committee prefs deadline, show the form
	elif request.user.is_staff:
		# Show a random school (the first one registered)
		# Admins can see the dashboard, but can't fill out any forms
		school = RegisteredSchool.objects.get(pk=27)

	com_assignments = school.committeeassignment_set.all()
	formset = CommitteeAssignmentFormSet(queryset=com_assignments, prefix='lol')
	scholar_forms = []
	for com_assignment in com_assignments:
		scholar_forms.append(ScholarshipIndividualFormset(queryset=com_assignment.scholarshipindividual_set.all(), prefix='%d' % com_assignment.id))

	data = {
		'management_forms': [formset.management_form] + [f.management_form for f in scholar_forms],
		'formset': zip(formset, scholar_forms),
		'unfilled_assignments': school.has_unfilled_assignments(),
		'school': school,
		'additional_pay': additional_pay,
		'form': form,
		'scholarshipfile': scholarshipfile,
		# Needed to show the title (as base.html expects the CMS view)
		'page': {
			'long_name': 'Your dashboard',
		},
	}

	return render(request, "dashboard.html", data)
Example #13
0
def dashboard(request):
    # If it's a dais member, redirect to that committee's position paper listing
    if request.user.username.endswith('@mcmun.org'):
        dais_committee = get_committee_from_email(request.user.username)
        if dais_committee:
            return redirect(dais_committee)

    form = None
    school = None
    event_form = None
    committees_form = None

    # Figure out how many delegates have registered for pub crawl so far
    # (hard cap after ~750 delegates have registered)
    pub_crawl_total = RegisteredSchool.objects.filter(num_pub_crawl__gt=0)\
                                            .aggregate(Sum('num_pub_crawl'))
    num_pub_crawl = pub_crawl_total['num_pub_crawl__sum']

    if request.user.registeredschool_set.count():
        # There should only be one anyway (see comment in models.py)
        school = request.user.registeredschool_set.filter(is_approved=True)[0]

        if not school.pub_crawl_final:
            event_form = EventForm(instance=school)

        # Iff there is no scholarship application with this school, show the form
        if ScholarshipApp.objects.filter(school=school).count() == 0:
            if request.method == 'POST':
                form = ScholarshipForm(request.POST)

                if form.is_valid():
                    scholarship_app = form.save(commit=False)
                    scholarship_app.school = school
                    scholarship_app.save()

                    # Show the "thank you for your application" message
                    form = None
            else:
                form = ScholarshipForm()

        # If we haven't passed the committee prefs deadline, show the form
        prefs_deadline = datetime.datetime(2013, 11, 20) # Nov 19 midnight
        if datetime.datetime.now() < prefs_deadline:
            committees_form = CommitteePrefsForm(instance=school)
    elif request.user.is_staff:
        # Show a random school (the first one registered)
        # Admins can see the dashboard, but can't fill out any forms
        school = RegisteredSchool.objects.get(pk=1)

    com_assignments = school.committeeassignment_set.all()
    formset = CommitteeAssignmentFormset(queryset=com_assignments, prefix='lol')
    del_forms = []
    for com_assignment in com_assignments:
        del_forms.append(DelegateAssignmentFormset(queryset=com_assignment.delegateassignment_set.all(), prefix='%d' % com_assignment.id))

    data = {
        'management_forms': [formset.management_form] + [f.management_form for f in del_forms],
        'formset': zip(formset, del_forms),
        'unfilled_assignments': school.has_unfilled_assignments(),
        'school': school,
        'event_form': event_form,
        'committees_form': committees_form,
        'form': form,
        # Needed to show the title (as base.html expects the CMS view)
        'title': 'Your dashboard',
        'pub_crawl_open': num_pub_crawl < 750,
    }

    return render(request, "dashboard.html", data)