Ejemplo n.º 1
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)
Ejemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        '''Log in a new user.'''
        if request.user.is_authenticated():
            raise PermissionDenied('Another user is currently logged in.')

        try:
            data = request.data
            user = User.authenticate(data['username'], data['password'])
        except AuthenticationError as e:
            raise AuthenticationFailed(str(e))

        login(request, user)
        return Response(UserSerializer(user).data,
                        status=status.HTTP_201_CREATED)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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,
        'position_papers_accepted': conference.position_papers_accepted,
    }

    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(request, 'www.html', context)
Ejemplo n.º 5
0
 def get(self, request, *args, **kwargs):
     '''Get the current user if they're authenticated.'''
     if not request.user.is_authenticated():
         raise Http404
     return Response(UserSerializer(request.user).data)