Пример #1
0
def new_user_registration(request, url_id):
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    context['page_title'] = _(u"User Operation")
    u = Url.objects.get(url_id=url_id)
    f = FirstTimeUser.objects.get(url=u)

    #zaman aşımı aşılmış mı diye kontrol
    now = datetime.datetime.now()
    time_difference = now - u.url_create_time
    total_seconds = 0
    try:
        total_seconds = time_difference.total_seconds()
    except:
        total_seconds = (time_difference.microseconds +
                         (time_difference.seconds +
                          time_difference.days * 24 * 3600) * 10**6) / 10**6
    if total_seconds > settings.LINK_TIMEOUT:
        context['info'] = 'new_user_link_timeout'
        return render_to_response("main/info.html",
                                  context_instance=RequestContext(
                                      request, context))

    context['url_id'] = url_id
    passwd = generate_passwd()
    ldap_handler = LdapHandler()
    status = ldap_handler.connect()
    if status:
        ldap_handler.bind()
    else:
        ldap_handler.unbind()
        raise Http404

    email = f.email
    if ldap_handler.search(email) == 1:  # zaten böyle bir kullanıcı kayitli
        context[
            'info'] = 'new_user_already_exists'  # bu linke daha onceden tiklayip
        # kendisini ldap'a kaydetmis ancak tekrar tiklayip kayit olmaya calisirsa
        ldap_handler.unbind()
        return render_to_response("main/info.html",
                                  context_instance=RequestContext(
                                      request, context))
    elif add_new_user(
            f, passwd,
            ldap_handler):  # ldap'a ekleme yapılıyorsa gosterilen sayfa
        #del request.META['HTTP_ACCEPT_LANGUAGE']
        language = translation.get_language_from_request(request)
        translation.activate(language)
        request.LANGUAGE_CODE = translation.get_language()
        context['info'] = 'new_user_info'
        context['email'] = email
        ldap_handler.unbind()
        return render_to_response("main/info.html",
                                  context_instance=RequestContext(
                                      request, context))
    else:
        ldap_handler.unbind()
        raise Http404
Пример #2
0
def new_user_registration(request, url_id):
    context = dict()
    context["welcome_header"] = settings.WELCOME_HEADER
    context["main_page"] = settings.MAIN_PAGE
    context["page_title"] = _(u"User Operation")
    u = Url.objects.get(url_id=url_id)
    f = FirstTimeUser.objects.get(url=u)

    # zaman aşımı aşılmış mı diye kontrol
    now = datetime.datetime.now()
    time_difference = now - u.url_create_time
    total_seconds = 0
    try:
        total_seconds = time_difference.total_seconds()
    except:
        total_seconds = (
            time_difference.microseconds + (time_difference.seconds + time_difference.days * 24 * 3600) * 10 ** 6
        ) / 10 ** 6
    if total_seconds > settings.LINK_TIMEOUT:
        context["info"] = "new_user_link_timeout"
        return render_to_response("main/info.html", context_instance=RequestContext(request, context))

    context["url_id"] = url_id
    passwd = generate_passwd()
    ldap_handler = LdapHandler()
    status = ldap_handler.connect()
    if status:
        ldap_handler.bind()
    else:
        ldap_handler.unbind()
        raise Http404

    email = f.email
    if ldap_handler.search(email) == 1:  # zaten böyle bir kullanıcı kayitli
        context["info"] = "new_user_already_exists"  # bu linke daha onceden tiklayip
        # kendisini ldap'a kaydetmis ancak tekrar tiklayip kayit olmaya calisirsa
        ldap_handler.unbind()
        return render_to_response("main/info.html", context_instance=RequestContext(request, context))
    elif add_new_user(f, passwd, ldap_handler):  # ldap'a ekleme yapılıyorsa gosterilen sayfa
        # del request.META['HTTP_ACCEPT_LANGUAGE']
        language = translation.get_language_from_request(request)
        translation.activate(language)
        request.LANGUAGE_CODE = translation.get_language()
        context["info"] = "new_user_info"
        context["email"] = email
        ldap_handler.unbind()
        return render_to_response("main/info.html", context_instance=RequestContext(request, context))
    else:
        ldap_handler.unbind()
        raise Http404
Пример #3
0
def new_user_registration(request,url_id):
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    context['page_title'] = _(u"Kullanıcı İşlemi")
    u = Url.objects.get(url_id=url_id)
    f = FirstTimeUser.objects.get(url=u)

    #zaman aşımı aşılmış mı diye kontrol
    now = datetime.datetime.now()
    time_difference = now - u.url_create_time
    total_seconds = 0
    try:
        total_seconds = time_difference.total_seconds()
    except:
        total_seconds =  (time_difference.microseconds + (time_difference.seconds + time_difference.days * 24 * 3600) * 10**6) / 10**6
    if total_seconds > settings.LINK_TIMEOUT:
        context['info'] = 'new_user_link_timeout'
        return render_to_response("main/info.html",
            context_instance=RequestContext(request, context))

    context['url_id'] = url_id
    passwd = generate_passwd()
    ldap_handler = LdapHandler()
    status = ldap_handler.connect()
    if status:
        ldap_handler.bind()
    else:
        ldap_handler.unbind()
        raise Http404

    email = f.email
    if ldap_handler.search(email) == 1: # zaten böyle bir kullanıcı kayitli
        context['info'] = 'new_user_already_exists' # bu linke daha onceden tiklayip
        # kendisini ldap'a kaydetmis ancak tekrar tiklayip kayit olmaya calisirsa
        ldap_handler.unbind()
        return render_to_response("main/info.html",
            context_instance=RequestContext(request, context))
    elif add_new_user(f, passwd, ldap_handler):  # ldap'a ekleme yapılıyorsa gosterilen sayfa
        context['info'] = 'new_user_info'
        context['email'] = email
        ldap_handler.unbind()
        return render_to_response("main/info.html",
            context_instance=RequestContext(request, context))
    else:
        ldap_handler.unbind()
        raise Http404
Пример #4
0
def guest_user_registration(request, url_id):
    #    guest = GuestUser.objects.get(url = url_id)
    #    email = guest.email
    #    name = guest.name
    #    middle_name = guest.middle_name
    #    surname = guest.surname
    #    password = generate_passwd()
    #    context = dict()
    #    context['url_id'] = url_id
    #    obj = LdapHandler()
    #    obj.connect()
    #    obj.bind()
    #    obj.add(name,middle_name,surname,email,password)
    #    obj.unbind()
    #    context['info'] = 'host_user_info' # konuk olunan kullanıcıya arkadaşına kullanıcı adı ve parolasının gittiğini belirtmek icin olan sayfa
    #    return render_to_response("main/info.html",
    #            context_instance=RequestContext(request, context))
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    context['page_title'] = _(u"Guest User Operation")
    u = Url.objects.get(url_id=url_id)
    guest = GuestUser.objects.get(url=u)

    #zaman aşımı aşılmış mı diye kontrol
    now = datetime.datetime.now()
    time_difference = now - u.url_create_time
    total_seconds = 0
    try:
        total_seconds = time_difference.total_seconds()
    except:
        total_seconds = (time_difference.microseconds +
                         (time_difference.seconds +
                          time_difference.days * 24 * 3600) * 10**6) / 10**6
    if total_seconds > settings.LINK_TIMEOUT:
        context['info'] = 'guest_user_link_timeout'
        return render_to_response("main/info.html",
                                  context_instance=RequestContext(
                                      request, context))

    context['url_id'] = url_id
    passwd = generate_passwd()
    ldap_handler = LdapHandler()
    status = ldap_handler.connect()
    if status:
        ldap_handler.bind()
    else:
        ldap_handler.unbind()
        raise Http404

    guest_user_email = guest.guest_user_email
    email = guest.email
    if ldap_handler.search(
            guest_user_email) == 1:  # zaten böyle bir kullanıcı kayitli
        context[
            'info'] = 'guest_user_already_exists'  # bu linke daha onceden tiklayip
        # kendisini ldap'a kaydetmis ancak tekrar tiklayip kayit olmaya calisirsa
        ldap_handler.unbind()
        return render_to_response("main/info.html",
                                  context_instance=RequestContext(
                                      request, context))
    elif add_new_user(
            guest, passwd, ldap_handler,
            guest_status=True):  # ldap'a ekleme yapılıyorsa gosterilen sayfa
        context['info'] = 'guest_user_info'
        context['email'] = email
        ldap_handler.unbind()
        return render_to_response("main/info.html",
                                  context_instance=RequestContext(
                                      request, context))
    else:
        ldap_handler.unbind()
        raise Http404
Пример #5
0
def guest_user_registration(request,url_id):
#    guest = GuestUser.objects.get(url = url_id)
#    email = guest.email
#    name = guest.name
#    middle_name = guest.middle_name
#    surname = guest.surname
#    password = generate_passwd()
#    context = dict()
#    context['url_id'] = url_id
#    obj = LdapHandler()
#    obj.connect()
#    obj.bind()
#    obj.add(name,middle_name,surname,email,password)
#    obj.unbind()
#    context['info'] = 'host_user_info' # konuk olunan kullanıcıya arkadaşına kullanıcı adı ve parolasının gittiğini belirtmek icin olan sayfa
#    return render_to_response("main/info.html",
#            context_instance=RequestContext(request, context))
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    context['page_title'] = _(u"Misafir Kullanıcı İşlemi")
    u = Url.objects.get(url_id=url_id)
    guest = GuestUser.objects.get(url=u)

    #zaman aşımı aşılmış mı diye kontrol
    now = datetime.datetime.now()
    time_difference = now - u.url_create_time
    total_seconds = 0
    try:
        total_seconds = time_difference.total_seconds()
    except:
        total_seconds =  (time_difference.microseconds + (time_difference.seconds + time_difference.days * 24 * 3600) * 10**6) / 10**6
    if total_seconds > settings.LINK_TIMEOUT:
        context['info'] = 'guest_user_link_timeout'
        return render_to_response("main/info.html",
            context_instance=RequestContext(request, context))

    context['url_id'] = url_id
    passwd = generate_passwd()
    ldap_handler = LdapHandler()
    status = ldap_handler.connect()
    if status:
        ldap_handler.bind()
    else:
        ldap_handler.unbind()
        raise Http404

    email = guest.guest_user_email
    if ldap_handler.search(email) == 1: # zaten böyle bir kullanıcı kayitli
        context['info'] = 'guest_user_already_exists' # bu linke daha onceden tiklayip
        # kendisini ldap'a kaydetmis ancak tekrar tiklayip kayit olmaya calisirsa
        ldap_handler.unbind()
        return render_to_response("main/info.html",
            context_instance=RequestContext(request, context))
    elif add_new_user(guest, passwd, ldap_handler, guest_status=True):  # ldap'a ekleme yapılıyorsa gosterilen sayfa
        context['info'] = 'guest_user_info'
        context['email'] = email
        ldap_handler.unbind()
        return render_to_response("main/info.html",
            context_instance=RequestContext(request, context))
    else:
        ldap_handler.unbind()
        raise Http404