예제 #1
0
def login(request):

    signin_form = EmailLoginForm()
    signup_form = ConferenceSignupForm()

    if request.method == "POST" and request.POST.get('action', None):
        if request.POST['action'] == 'signin':
            signin_form = EmailLoginForm(request.POST)
            if signin_form.is_valid():
                user = signin_form.user
                user.is_bulk = False
                user.save()
                auth.login(request, user)
                return HttpResponseRedirect(reverse('confreg'))
        else:
            signup_form = ConferenceSignupForm(request.POST)

            if signup_form.is_valid():
                username, password = signup_form.save()
                user = auth.authenticate(username=username, password=password)
                auth.login(request, user)

                return HttpResponseRedirect(reverse('confreg'))

    return render_to_response('conference/login.html', {
        "signin_form": signin_form,
        "signup_form": signup_form
    },
                              context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: alexnjoyce/myewb2
def login(request):
    
    signin_form = EmailLoginForm()
    signup_form = ConferenceSignupForm()
    
    if request.method == "POST" and request.POST.get('action', None):
        if request.POST['action'] == 'signin':
            signin_form = EmailLoginForm(request.POST)
            if signin_form.is_valid():
                user = signin_form.user
                user.is_bulk = False
                user.save()
                auth.login(request, user)
                return HttpResponseRedirect(reverse('confreg'))
        else:
            signup_form = ConferenceSignupForm(request.POST)
            
            if signup_form.is_valid():
                username, password = signup_form.save()
                user = auth.authenticate(username=username, password=password)
                auth.login(request, user)
                
                return HttpResponseRedirect(reverse('confreg'))
        
    return render_to_response('conference/login.html',
                              {"signin_form": signin_form,
                               "signup_form": signup_form},
                              context_instance = RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: alexnjoyce/myewb2
def login(request):
    form = EmailLoginForm(request.POST)
    if form.login(request):
        response = {
                'username': form.user.username,
                'message': 'Successfully logged in.',
                'success': True,
        }
    else:
        response = {
                'message': 'Your login credentials did not match. Please try again.',
                'success': False,
                'login_name': request.POST['login_name'],
        }
    return HttpResponse(json.dumps(response))
예제 #4
0
def login(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse("conference_schedule"))

    signin_form = EmailLoginForm(initial={"remember": "on"})

    if request.method == "POST":
        signin_form = EmailLoginForm(request.POST)
        if signin_form.is_valid():
            user = signin_form.user
            auth.login(request, user)
            return HttpResponseRedirect(reverse("conference_schedule"))

    return render_to_response(
        "conference/schedule/login.html", {"form": signin_form}, context_instance=RequestContext(request)
    )
예제 #5
0
def login(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse('conference_schedule'))

    signin_form = EmailLoginForm(initial={'remember': 'on'})

    if request.method == "POST":
        signin_form = EmailLoginForm(request.POST)
        if signin_form.is_valid():
            user = signin_form.user
            auth.login(request, user)
            return HttpResponseRedirect(reverse('conference_schedule'))

    return render_to_response("conference/schedule/login.html",
                              {'form': signin_form},
                              context_instance=RequestContext(request))
예제 #6
0
def login(request):
    form = EmailLoginForm(request.POST)
    if form.login(request):
        response = {
            'username': form.user.username,
            'message': 'Successfully logged in.',
            'success': True,
        }
    else:
        response = {
            'message':
            'Your login credentials did not match. Please try again.',
            'success': False,
            'login_name': request.POST['login_name'],
        }
    return HttpResponse(json.dumps(response))
예제 #7
0
파일: views.py 프로젝트: franciskung/myewb2
def login(request):
    
    signin_form = EmailLoginForm()
    signup_form = ConferenceSignupForm()
    
    if request.method == "POST" and request.POST.get('action', None):
        if request.POST['action'] == 'signin':
            signin_form = EmailLoginForm(request.POST)
            if signin_form.is_valid():
                user = signin_form.user
                user.is_bulk = False
                user.save()
                auth.login(request, user)

                if request.POST.get('language', 'english') == 'french':
                    request.session['conflang'] = 'fr'
                    request.session['django_language'] = 'fr_FR'
                else:
                    request.session['conflang'] = 'en'
                    request.session['django_language'] = 'en_US'
                
                return HttpResponseRedirect(reverse('confreg'))
        else:
            signup_form = ConferenceSignupForm(request.POST)
            
            if signup_form.is_valid():
                username, password = signup_form.save()
                user = auth.authenticate(username=username, password=password)
                auth.login(request, user)

                if request.META['SERVER_NAME'] == 'conference2013.ewb.ca':
                    return HttpResponseRedirect(reverse('conference_questionnaire'))
                else:
                    return HttpResponseRedirect(reverse('confreg'))
        
    return render_to_response('conference/login.html',
                              {"signin_form": signin_form,
                               "signup_form": signup_form},
                              context_instance = RequestContext(request))
예제 #8
0
def topics(request,
           group_slug=None,
           form_class=GroupTopicForm,
           attach_form_class=AttachmentForm,
           template_name="topics/topics.html",
           bridge=None,
           mode=None):

    if request.is_ajax() or request.GET.get('ajax', None):
        template_name = "topics/topics_ajax.html"

    # kinda hack-ish.  but the easiest way; doesn't feel worth adding an AJAX param for this.
    if group_slug == 'featured':
        mode = 'featured'
        group_slug = None

    is_member = False
    group = None
    if group_slug is not None:
        group = get_object_or_404(BaseGroup, slug=group_slug)
        is_member = group.user_is_member(request.user, admin_override=True)

    if group and not group.is_visible(request.user):
        return HttpResponseForbidden()

    attach_count = 0
    if request.method == "POST" and group:
        return new_topic(request, group_slug)
    else:
        topic_form = form_class(instance=GroupTopic(),
                                user=request.user,
                                group=group)

        attach_forms = []

    # if it's a listing by group, check group visibility
    if group:
        topics = GroupTopic.objects.get_for_group(group)

    # otherwise throw up a generic listing of visible posts
    else:
        # generic topic listing: show posts from groups you're in
        # also shows posts from public groups...
        # for guests, show posts from public groups only
        topics = GroupTopic.objects.visible(user=request.user)

    if mode == 'featured':
        topics = GroupTopic.objects.featured(topics)
    elif mode == 'newposts' and request.user.is_authenticated():
        topics = GroupTopic.objects.since(
            request.user.get_profile().previous_login, qs=topics)
    elif mode == 'newreplies' and request.user.is_authenticated():
        topics = GroupTopic.objects.replies_since(
            request.user.get_profile().previous_login, qs=topics)

    if request.user.is_authenticated():
        can_adminovision = user_can_adminovision(request.user)
        can_execovision = user_can_execovision(request.user)
        adminovision = request.user.get_profile().adminovision

        if not request.user.get_profile().show_emails:
            topics = GroupTopic.objects.exclude_emails(topics)

    else:
        can_adminovision = False
        can_execovision = False
        adminovision = False

    # also kinda hackish
    if group and group.slug == "ewb":
        group = None
        mode = "frontpage"
    elif not group and not mode:
        mode = "latest"

    return render_to_response(
        template_name,
        {
            "group": group,
            "topic_form": topic_form,
            "attach_forms": attach_forms,
            "attach_count": attach_count,
            "is_member": is_member,
            "topics": topics,
            "can_adminovision": can_adminovision,
            "can_execovision": can_execovision,
            "adminovision": adminovision,
            "login_form": EmailLoginForm(),  # for front-page toolbar
            "mode": mode
        },
        context_instance=RequestContext(request))