예제 #1
0
파일: views.py 프로젝트: jawoonkim/huxley
def reset_password(request):
    '''Reset a user's password.'''
    if request.method == 'POST':
        username = request.POST.get('username')
        new_password = HuxleyUser.reset_password(username)
        if new_password:
            if True:
                user.email_user("Huxley Password Reset",
                                "Your password has been reset to %s.\nThank you for using Huxley!" % (new_password),
                                from_email="*****@*****.**")
            return render_template(request, 'password-reset-success.html')
        else:
            return render_template(request, 'password-reset.html', {'error': True})

    return render_template(request, 'password-reset.html')
예제 #2
0
def welcome(request):
    """ Display and/or edit the advisor's profile information. """
    school = request.user.school
    if request.method == 'GET':
        return render_template(request, 'welcome.html', {'school': school})

    elif request.method == 'POST':
        # TODO (wchieng): refactor this into a Django form.
        request.user.first_name = request.POST.get('firstname')
        request.user.last_name = request.POST.get('lastname')
        request.user.save();
        school.name = request.POST.get('schoolname')
        school.address = request.POST.get('address')
        school.city = request.POST.get('city')
        school.zip_code = request.POST.get('zip_code')
        school.program_type = request.POST.get('program_type')
        school.times_attended = request.POST.get('attendance')
        school.primary_name = request.POST.get('primary_name')
        school.primary_email = request.POST.get('primary_email')
        school.primary_phone = request.POST.get('primary_phone')
        school.secondary_name = request.POST.get('secname')
        school.secondary_email = request.POST.get('secemail')
        school.secondary_phone = request.POST.get('secphone')
        school.min_delegation_size = request.POST.get('minDel')
        school.max_delegation_size = request.POST.get('maxDel')
        school.save();

        return HttpResponse()
예제 #3
0
def help(request):
    """ Display a FAQ view. """
    questions = {
        category.name: HelpQuestion.objects.filter(category=category)
        for category in HelpCategory.objects.all()
    }
    return render_template(request, 'help.html', {'categories': questions})
예제 #4
0
def index(request):
    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {'user_json': json.dumps(user_dict)}
    return render_template(request, 'www.html', context)
예제 #5
0
파일: views.py 프로젝트: jawoonkim/huxley
def reset_password(request):
    '''Reset a user's password.'''
    if request.method == 'POST':
        username = request.POST.get('username')
        new_password = HuxleyUser.reset_password(username)
        if new_password:
            if True:
                user.email_user(
                    "Huxley Password Reset",
                    "Your password has been reset to %s.\nThank you for using Huxley!"
                    % (new_password),
                    from_email="*****@*****.**")
            return render_template(request, 'password-reset-success.html')
        else:
            return render_template(request, 'password-reset.html',
                                   {'error': True})

    return render_template(request, 'password-reset.html')
예제 #6
0
파일: views.py 프로젝트: mmmccarthy/huxley
def press_release(request):
    """ Display the Press Release page for chairs. """
    com = request.user.committee
    if request.method == 'POST':
        delegate_slots = simplejson.loads(request.POST['delegate_slots'])
        for slot_data in delegate_slots:
            delegate = Delegate.objects.get(delegate_slot=DelegateSlot.objects.get(id=slot_data['id']))
            delegate.release = slot_data['textfield']
            delegate.save()
        return HttpResponse()
    delegate_slots = DelegateSlot.objects.filter(assignment__committee=com).order_by('assignment__country__name')
    return render_template(request, 'pressrelease.html', {'delegate_slots': delegate_slots})
예제 #7
0
def roster(request):
    """ Display the advisor's editable roster, or update information as
        necessary. """
    school = request.user.school
    if request.method == 'POST':
        slot_data = json.loads(request.POST['delegates'])
        school.update_delegate_slots(slot_data)

        return HttpResponse()

    slots = school.get_delegate_slots()
    return render_template(request, 'roster_edit.html', {'slots' : slots})
예제 #8
0
파일: views.py 프로젝트: mmmccarthy/huxley
def attendance(request):
    """ Display a page allowing the chair to take attendance. """
    committee = request.user.committee
    if request.method == 'POST':
        delegate_slots = simplejson.loads(request.POST['delegate_slots'])
        for slot_data in delegate_slots:
            slot = DelegateSlot.objects.get(id=slot_data['id'])
            slot.update_delegate_attendance(slot_data)
        return HttpResponse()

    delegate_slots = DelegateSlot.objects.filter(assignment__committee=committee).order_by('assignment__country__name')

    return render_template(request, 'take_attendance.html', {'delegate_slots': delegate_slots})
예제 #9
0
파일: views.py 프로젝트: jmosky12/huxley
def index(request):
    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {
        'user_json': json.dumps(user_dict).replace('</', '<\\/'),
        'gender_constants': ContactGender.to_json(),
        'contact_types': ContactType.to_json(),
        'program_types': ProgramTypes.to_json(),
    }

    return render_template(request, 'www.html', context)
예제 #10
0
파일: views.py 프로젝트: mmmccarthy/huxley
def login_user(request):
    '''Log in a user or render the login template.'''
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')

        user, error = HuxleyUser.authenticate(username, password)
        if error:
            return render_json({'success': False, 'error': error})
        redirect = HuxleyUser.login(request, user)
        return render_json({'success': True, 'redirect': redirect})

    return render_template(request, 'login.html')
예제 #11
0
파일: views.py 프로젝트: jawoonkim/huxley
def register(request):
    '''Register a new user and school.'''

    if not Conference.objects.get(session=62).open_reg:
        return render_template(request, 'registration-closed.html')

    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_school = form.create_school()
            new_user = form.create_user(new_school)
            form.add_country_preferences(new_school)
            form.add_committee_preferences(new_school)

            if new_school.waitlist:
                return render_template(request, 'registration-waitlist.html')
            if not settings.DEBUG:
                new_user.email_user(
                    "Thanks for registering for BMUN 62!",
                    "We're looking forward to seeing %s at BMUN 62. "
                    "You can find information on deadlines and fees at "
                    "http://bmun.org/bmun/timeline/. If you have any "
                    "more questions, please feel free to email me at "
                    "[email protected]. See you soon!\n\nBest,\n\nShrey Goel"
                    "\nUSG of External Relations, BMUN 62" % new_school.name,
                    "*****@*****.**")
            Conference.auto_country_assign(new_school)
            return render_template(request, 'registration-success.html')

    form = RegistrationForm()
    context = {
        'form': form,
        'state': '',
        'countries': Country.objects.filter(special=False).order_by('name'),
        'committees': Committee.objects.filter(special=True),
        'waitlist': Conference.objects.get(session=62).waitlist_reg
    }

    return render_template(request, 'registration.html', context)
예제 #12
0
파일: views.py 프로젝트: jawoonkim/huxley
def register(request):
    '''Register a new user and school.'''

    if not Conference.objects.get(session=62).open_reg:
        return render_template(request, 'registration-closed.html')

    if request.method =='POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_school = form.create_school()
            new_user = form.create_user(new_school)
            form.add_country_preferences(new_school)
            form.add_committee_preferences(new_school)

            if new_school.waitlist:
                return render_template(request, 'registration-waitlist.html')
            if not settings.DEBUG:
                new_user.email_user("Thanks for registering for BMUN 62!",
                                    "We're looking forward to seeing %s at BMUN 62. "
                                    "You can find information on deadlines and fees at "
                                    "http://bmun.org/bmun/timeline/. If you have any "
                                    "more questions, please feel free to email me at "
                                    "[email protected]. See you soon!\n\nBest,\n\nShrey Goel"
                                    "\nUSG of External Relations, BMUN 62" % new_school.name,
                                    "*****@*****.**")
            Conference.auto_country_assign(new_school)
            return render_template(request, 'registration-success.html')

    form = RegistrationForm()
    context = {
        'form': form,
        'state': '',
        'countries': Country.objects.filter(special=False).order_by('name'),
        'committees': Committee.objects.filter(special=True),
        'waitlist': Conference.objects.get(session=62).waitlist_reg
    }

    return render_template(request, 'registration.html', context)
예제 #13
0
    def process_request(self, request):
        app_name = resolve(request.path_info).app_name

        if not app_name in ('advisors', 'chairs'):
            return

        if not request.user.is_authenticated():
            return render_template(request, 'login.html')

        if app_name == 'advisors' and not request.user.is_advisor():
            return HttpResponseForbidden()

        if app_name == 'chairs' and not request.user.is_chair():
            return HttpResponseForbidden()
예제 #14
0
    def process_request(self, request):
        app_name = resolve(request.path_info).app_name

        if not app_name in ('advisors', 'chairs'):
            return

        if not request.user.is_authenticated():
            return render_template(request, 'login.html')

        if app_name == 'advisors' and not request.user.is_advisor():
            return HttpResponseForbidden()

        if app_name == 'chairs' and not request.user.is_chair():
            return HttpResponseForbidden()
예제 #15
0
파일: views.py 프로젝트: jawoonkim/huxley
def login_user(request):
    '''Log in a user or render the login template.'''
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')

        try:
            user = HuxleyUser.authenticate(username, password)
        except AuthenticationError as e:
            return render_json({'success': False, 'error': str(e)})

        redirect = HuxleyUser.login(request, user)
        return render_json({'success': True, 'redirect': redirect})

    return render_template(request, 'login.html')
예제 #16
0
def attendance(request):
    """ Display a page allowing the chair to take attendance. """
    committee = request.user.committee
    if request.method == 'POST':
        delegate_slots = json.loads(request.POST['delegate_slots'])
        for slot_data in delegate_slots:
            slot = DelegateSlot.objects.get(id=slot_data['id'])
            slot.update_delegate_attendance(slot_data)
        return HttpResponse()

    delegate_slots = DelegateSlot.objects.filter(
        assignment__committee=committee).order_by('assignment__country__name')

    return render_template(request, 'take_attendance.html',
                           {'delegate_slots': delegate_slots})
예제 #17
0
def summaries(request):
    """ Display the summaries page for chairs. """
    com = request.user.committee
    if request.method == 'POST':
        delegate_slots = json.loads(request.POST['delegate_slots'])
        for slot_data in delegate_slots:
            delegate = Delegate.objects.get(
                delegate_slot=DelegateSlot.objects.get(id=slot_data['id']))
            delegate.summary = slot_data['textfield']
            delegate.save()
        return HttpResponse()
    delegate_slots = DelegateSlot.objects.filter(
        assignment__committee=com).order_by('assignment__country__name')
    return render_template(request, 'summaries.html',
                           {'delegate_slots': delegate_slots})
예제 #18
0
def index(request):
    if request.user.is_superuser:
        return redirect(reverse('admin:index'))

    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {
        'user_json': json.dumps(user_dict).replace('</', '<\\/'),
        'gender_constants': ContactGender.to_json(),
        'contact_types': ContactType.to_json(),
        'program_types': ProgramTypes.to_json(),
    }

    return render_template(request, 'www.html', context)
예제 #19
0
파일: views.py 프로젝트: hmuntest/huxley
def index(request):
    if request.user.is_superuser:
        return redirect(reverse('admin:index'))

    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {
        'user_json': json.dumps(user_dict).replace('</', '<\\/'),
        'conference_session': Conference.objects.all().aggregate(Max('session'))['session__max'],
        'gender_constants': ContactGender.to_json(),
        'contact_types': ContactType.to_json(),
        'program_types': ProgramTypes.to_json(),
    }

    return render_template(request, 'www.html', context)
예제 #20
0
def preferences(request):
    """ Display and/or update the advisor's country and committee
        preferences. """
    return render_to_response('coming-soon.html')
    school = request.user.school

    if request.method == 'POST':
        country_ids = request.POST.getlist('CountryPrefs')
        committee_ids = request.POST.getlist('CommitteePrefs')
        school.update_country_preferences(country_ids)
        school.update_committee_preferences(committee_ids)
        return HttpResponse()

    context = {
        'countries': Country.objects.filter(special=False).order_by('name'),
        'countryprefs': CountryPreference.shuffle(school.get_country_preferences()),
        'committees': pairwise(Committee.objects.filter(special=True)),
        'committeeprefs': school.committeepreferences.all()
    }

    return render_template(request, 'preferences.html', context)
예제 #21
0
파일: views.py 프로젝트: jtiannn/huxley
def index(request):
    if request.user.is_superuser:
        return redirect(reverse('admin:index'))

    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    conference = Conference.get_current()

    conference_dict = {
        'session': conference.session,
        'start_date': {
            'month': conference.start_date.strftime('%B'),
            'day': conference.start_date.strftime('%d'),
            'year': conference.start_date.strftime('%Y')
        },
        'end_date': {
            'month': conference.end_date.strftime('%B'),
            'day': conference.end_date.strftime('%d'),
            'year': conference.end_date.strftime('%Y')
        },
        'external': conference.external,
        'registration_fee': int(conference.registration_fee),
        'delegate_fee': int(conference.delegate_fee),
        'registration_open': conference.open_reg,
        'registration_waitlist': conference.waitlist_reg,
    }

    context = {
        'user_json': json.dumps(user_dict).replace('</', '<\\/'),
        'conference_json': json.dumps(conference_dict),
        'gender_constants': ContactGender.to_json(),
        'contact_types': ContactType.to_json(),
        'program_types': ProgramTypes.to_json(),
    }

    return render_template(request, 'www.html', context)
예제 #22
0
def index(request):
    if request.user.is_superuser:
        return redirect(reverse('admin:index'))

    user_dict = {}
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    conference = Conference.get_current()

    conference_dict = {
        'session': conference.session,
        'start_date': {
            'month': conference.start_date.strftime('%B'),
            'day': conference.start_date.strftime('%d'),
            'year': conference.start_date.strftime('%Y')
        },
        'end_date': {
            'month': conference.end_date.strftime('%B'),
            'day': conference.end_date.strftime('%d'),
            'year': conference.end_date.strftime('%Y')
        },
        'external': conference.external,
        'registration_fee': int(conference.registration_fee),
        'delegate_fee': int(conference.delegate_fee),
        'registration_open': conference.open_reg,
        'registration_waitlist': conference.waitlist_reg,
    }

    context = {
        'user_json': json.dumps(user_dict).replace('</', '<\\/'),
        'conference_json': json.dumps(conference_dict),
        'gender_constants': ContactGender.to_json(),
        'contact_types': ContactType.to_json(),
        'program_types': ProgramTypes.to_json(),
    }

    return render_template(request, 'www.html', context)
예제 #23
0
파일: views.py 프로젝트: mmmccarthy/huxley
def bugs(request):
    """ Display a bug reporting view. """
    return render_template(request, 'bugs.html')
예제 #24
0
파일: views.py 프로젝트: mmmccarthy/huxley
def help(request):
    """ Display a FAQ view. """
    questions = {category.name: HelpQuestion.objects.filter(category=category)
                 for category in HelpCategory.objects.all()}
    return render_template(request, 'help.html', {'categories': questions})
예제 #25
0
def attendance(request):
    """ Display the advisor's attendance list. """
    context = {'delegate_slots': request.user.school.get_delegate_slots()}
    return render_template(request, 'check-attendance.html', context)
예제 #26
0
def summaries_advisors(request):
    context = {'delegate_slots': request.user.school.get_delegate_slots()}
    return render_template(request, 'summaries_advisors.html', context)
예제 #27
0
def bugs(request):
    """ Display a bug reporting view. """
    return render_template(request, 'bugs.html')