Пример #1
0
def guest_user(request):
    raise Http404
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    context['page_title'] = _(u"Misafir Kullanıcı Sayfası")
    form = GuestUserForm()
    if request.method == "POST":
        form = GuestUserForm(request.POST)
        if form.is_valid():
           name = request.POST['name']
           middle_name = request.POST['middle_name']
           surname = request.POST['surname']
           guest_user_email = request.POST['guest_user_email']
           email = request.POST['email']
           guest_user_phone = request.POST['guest_user_phone']
           surname = upper_function(surname)
           name=upper_function(name)
           middle_name = upper_function(middle_name)
           type = request.POST['type']
           time_duration = request.POST['time_duration']
           ldap_handler = LdapHandler()
           bind_status = False
           if ldap_handler.connect():
               bind_status = ldap_handler.bind()
           if bind_status:
               if ldap_handler.search(guest_user_email) == 1:  # eger kayıt olmak isteyen misafir zaten ldap'ta kayıtllıysa
                   ldap_handler.unbind()
                   context['form'] = form
                   context['web']  = "guest_user"
                   context['page_title'] = _(u"Misafir Kullanıcı Başvurusu")
                   context['info'] = "guest_user_already_exist"
                   context['email'] = guest_user_email
                   return render_to_response("main/info.html",
                       context_instance=RequestContext(request, context))
               url = generate_url_id()
               url_obj = Url.objects.create(url_id=url)
               guest_user_obj = GuestUser.objects.create(name=name,middle_name=middle_name,
                   surname=surname,email=email,guest_user_email=guest_user_email,url=url_obj,
                   guest_user_phone=guest_user_phone, type=type, time_duration=time_duration)
               send_guest_user_confirm(guest_user_obj) # misafir kullanıcıya ev sahibi kullanıcıya mail atıldıgının bildirilmesi
               context['form'] = form
               context['web']  = "guest_user"
               context['info'] = 'guest_mail_confirm'
               context['host_email'] = email
               context['email'] = guest_user_email
               return render_to_response("main/info.html",
                       context_instance=RequestContext(request, context))
        else:
            context['form'] = form
            context['web']  = "guest_user"
            return render_to_response("guest_user/guest_user.html",
                context_instance=RequestContext(request, context))
    else:
        context['form'] = form
        context['web']  = "guest_user"
        return render_to_response("guest_user/guest_user.html",
            context_instance=RequestContext(request, context))
Пример #2
0
def new_user(request):
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    form = FirstTimeUserForm()
    if request.method == "POST":
        form = FirstTimeUserForm(request.POST)
        if form.is_valid():
            human = True
            name = request.POST['name']
            middle_name = request.POST['middle_name']
            surname = request.POST['surname']
            email = request.POST['email']
            faculty_id = request.POST['faculty']
            department_id = request.POST['department']
            ldap_handler = LdapHandler()
            bind_status = False
            if ldap_handler.connect():
                bind_status = ldap_handler.bind()
            if bind_status:
                #TODO: forma epostadaki domain uzantısı için kontrol koymak lazım
                if ldap_handler.search(
                        email) == 1:  # zaten böyle bir kullanıcı kayıtlı
                    context['form'] = form
                    context['web'] = "new_user"
                    context['info'] = "new_user_already_exist"
                    context['email'] = email
                    return render_to_response("main/info.html",
                                              context_instance=RequestContext(
                                                  request, context))
                else:  # eğer boyle bir kullanıcı yoksa onaylama linkinin olduğu bir mail atar.
                    generated_url = generate_url_id()
                    url_obj = Url.objects.create(url_id=generated_url)
                    department = Department.objects.get(id=int(department_id))
                    faculty = Faculty.objects.get(id=int(faculty_id))
                    name = upper_function(name)
                    if middle_name:
                        middle_name = upper_function(middle_name)
                    surname = upper_function(surname)
                    first_time_obj = FirstTimeUser.objects.create(
                        name=name,
                        middle_name=middle_name,
                        surname=surname,
                        faculty=faculty,
                        department=department,
                        email=email,
                        url=url_obj)
                    status = send_new_user_confirm(
                        email, generated_url,
                        url_obj)  # onaylama linkinin olduğu mail
                    ldap_handler.unbind()
                    if status:
                        context['form'] = form
                        context['web'] = "new_user"
                        context['email'] = email
                        context[
                            'info'] = "mail_confirm"  # onaylama linkini gonderdigimiz belirten mesaj
                        return render_to_response(
                            "main/info.html",
                            context_instance=RequestContext(request, context))
                    else:
                        raise Http404
        else:
            context['page_title'] = _(u"New User Application")
            context['form'] = form
            context['web'] = "new_user"
            return render_to_response("new_user/form.html",
                                      context_instance=RequestContext(
                                          request, context))
    else:
        context['page_title'] = _(u"New User Application")
        context['form'] = form
        context['web'] = "new_user"
        return render_to_response("new_user/form.html",
                                  context_instance=RequestContext(
                                      request, context))
Пример #3
0
def guest_user(request):
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    context['page_title'] = _(u"Guest User Page")
    form = GuestUserForm()
    if request.method == "POST":
        form = GuestUserForm(request.POST)
        if form.is_valid():
            name = request.POST['name']
            middle_name = request.POST['middle_name']
            surname = request.POST['surname']
            guest_user_email = request.POST['guest_user_email']
            email = request.POST['email']
            guest_user_phone = request.POST['guest_user_phone']
            surname = upper_function(surname)
            name = upper_function(name)
            middle_name = upper_function(middle_name)
            type = request.POST['type']
            time_duration = request.POST['time_duration']
            citizen_no = request.POST['citizen_no']
            ldap_handler = LdapHandler()
            bind_status = False
            if ldap_handler.connect():
                bind_status = ldap_handler.bind()
            if bind_status:
                if ldap_handler.search(
                        guest_user_email
                ) == 1:  # eger kayıt olmak isteyen misafir zaten ldap'ta kayıtllıysa
                    ldap_handler.unbind()
                    context['form'] = form
                    context['web'] = "guest_user"
                    context['page_title'] = _(u"Guest User Application")
                    context['info'] = "guest_user_already_exist"
                    context['email'] = guest_user_email
                    return render_to_response("main/info.html",
                                              context_instance=RequestContext(
                                                  request, context))
                url = generate_url_id()
                url_obj = Url.objects.create(url_id=url)
                guest_user_obj = GuestUser.objects.create(
                    name=name,
                    middle_name=middle_name,
                    surname=surname,
                    email=email,
                    guest_user_email=guest_user_email,
                    url=url_obj,
                    guest_user_phone=guest_user_phone,
                    type=type,
                    time_duration=time_duration,
                    citizen_no=citizen_no)
                # kullanıcının son geçerlilik süresi yazılıyor
                now = datetime.datetime.now()
                guest_user_obj.application_time = now
                application_time = guest_user_obj.application_time
                time_duration = int(guest_user_obj.time_duration)
                deadline_time = now
                if int(guest_user_obj.type) == 1:  # SAAT
                    deadline_time = application_time + datetime.timedelta(
                        hours=time_duration)
                if int(guest_user_obj.type) == 2:  # GUN
                    deadline_time = application_time + datetime.timedelta(
                        days=time_duration)
                if int(guest_user_obj.type) == 3:  # HAFTA
                    deadline_time = application_time + datetime.timedelta(
                        weeks=time_duration)

                guest_user_obj.deadline_time = deadline_time
                guest_user_obj.save()

                send_guest_user_confirm(
                    guest_user_obj
                )  # misafir kullanıcıya ev sahibi kullanıcıya mail atıldıgının bildirilmesi
                context['form'] = form
                context['web'] = "guest_user"
                context['info'] = 'guest_mail_confirm'
                context['host_email'] = email
                context['email'] = guest_user_email
                return render_to_response("main/info.html",
                                          context_instance=RequestContext(
                                              request, context))
        else:
            context['form'] = form
            context['web'] = "guest_user"
            return render_to_response("guest_user/guest_user.html",
                                      context_instance=RequestContext(
                                          request, context))
    else:
        context['form'] = form
        context['web'] = "guest_user"
        return render_to_response("guest_user/guest_user.html",
                                  context_instance=RequestContext(
                                      request, context))
Пример #4
0
def new_user(request):
    context = dict()
    context['welcome_header'] = settings.WELCOME_HEADER
    context['main_page'] = settings.MAIN_PAGE
    form = FirstTimeUserForm()
    if request.method == "POST":
        form = FirstTimeUserForm(request.POST)
        if form.is_valid():
            human = True
            name = request.POST['name']
            middle_name  = request.POST['middle_name']
            surname  = request.POST['surname']
            email = request.POST['email']
            faculty_id = request.POST['faculty']
            department_id = request.POST['department']
            ldap_handler = LdapHandler()
            bind_status = False
            if ldap_handler.connect():
                bind_status = ldap_handler.bind()
            if bind_status:
                #TODO: forma epostadaki domain uzantısı için kontrol koymak lazım
                if ldap_handler.search(email) == 1: # zaten böyle bir kullanıcı kayıtlı
                    context['form'] = form
                    context['web']  = "new_user"
                    context['info'] = "new_user_already_exist"
                    context['email'] = email
                    return render_to_response("main/info.html",
                        context_instance=RequestContext(request, context))
                else:  # eğer boyle bir kullanıcı yoksa onaylama linkinin olduğu bir mail atar.
                    generated_url = generate_url_id()
                    url_obj = Url.objects.create(url_id=generated_url)
                    department = Department.objects.get(id=int(department_id))
                    faculty = Faculty.objects.get(id=int(faculty_id))
                    name=upper_function(name)
                    if middle_name:
                        middle_name = upper_function(middle_name)
                    surname = upper_function(surname)
                    first_time_obj = FirstTimeUser.objects.create(name=name, middle_name=middle_name,
                        surname=surname, faculty=faculty, department=department, email=email, url=url_obj)
                    status = send_new_user_confirm(email, generated_url, url_obj)  # onaylama linkinin olduğu mail
                    ldap_handler.unbind()
                    if status:
                        context['form'] = form
                        context['web']  = "new_user"
                        context['email'] = email
                        context['info'] = "mail_confirm" # onaylama linkini gonderdigimiz belirten mesaj
                        return render_to_response("main/info.html",
                            context_instance=RequestContext(request, context))
                    else:
                        raise Http404
        else:
            context['page_title'] = _(u"Yeni Kullanıcı Başvurusu")
            context['form'] = form
            context['web']  = "new_user"
            return render_to_response("new_user/form.html",
                context_instance=RequestContext(request, context))
    else:
        context['page_title'] = _(u"Yeni Kullanıcı Başvurusu")
        context['form'] = form
        context['web']  = "new_user"
        return render_to_response("new_user/form.html",
            context_instance=RequestContext(request, context))
Пример #5
0
def guest_user(request):
    context = dict()
    context["welcome_header"] = settings.WELCOME_HEADER
    context["main_page"] = settings.MAIN_PAGE
    context["page_title"] = _(u"Guest User Page")
    form = GuestUserForm()
    if request.method == "POST":
        form = GuestUserForm(request.POST)
        if form.is_valid():
            name = request.POST["name"]
            middle_name = request.POST["middle_name"]
            surname = request.POST["surname"]
            guest_user_email = request.POST["guest_user_email"]
            email = request.POST["email"]
            guest_user_phone = request.POST["guest_user_phone"]
            surname = upper_function(surname)
            name = upper_function(name)
            middle_name = upper_function(middle_name)
            type = request.POST["type"]
            time_duration = request.POST["time_duration"]
            citizen_no = request.POST["citizen_no"]
            ldap_handler = LdapHandler()
            bind_status = False
            if ldap_handler.connect():
                bind_status = ldap_handler.bind()
            if bind_status:
                if (
                    ldap_handler.search(guest_user_email) == 1
                ):  # eger kayıt olmak isteyen misafir zaten ldap'ta kayıtllıysa
                    ldap_handler.unbind()
                    context["form"] = form
                    context["web"] = "guest_user"
                    context["page_title"] = _(u"Guest User Application")
                    context["info"] = "guest_user_already_exist"
                    context["email"] = guest_user_email
                    return render_to_response("main/info.html", context_instance=RequestContext(request, context))
                url = generate_url_id()
                url_obj = Url.objects.create(url_id=url)
                guest_user_obj = GuestUser.objects.create(
                    name=name,
                    middle_name=middle_name,
                    surname=surname,
                    email=email,
                    guest_user_email=guest_user_email,
                    url=url_obj,
                    guest_user_phone=guest_user_phone,
                    type=type,
                    time_duration=time_duration,
                    citizen_no=citizen_no,
                )
                # kullanıcının son geçerlilik süresi yazılıyor
                now = datetime.datetime.now()
                guest_user_obj.application_time = now
                application_time = guest_user_obj.application_time
                time_duration = int(guest_user_obj.time_duration)
                deadline_time = now
                if int(guest_user_obj.type) == 1:  # SAAT
                    deadline_time = application_time + datetime.timedelta(hours=time_duration)
                if int(guest_user_obj.type) == 2:  # GUN
                    deadline_time = application_time + datetime.timedelta(days=time_duration)
                if int(guest_user_obj.type) == 3:  # HAFTA
                    deadline_time = application_time + datetime.timedelta(weeks=time_duration)

                guest_user_obj.deadline_time = deadline_time
                guest_user_obj.save()

                send_guest_user_confirm(
                    guest_user_obj
                )  # misafir kullanıcıya ev sahibi kullanıcıya mail atıldıgının bildirilmesi
                context["form"] = form
                context["web"] = "guest_user"
                context["info"] = "guest_mail_confirm"
                context["host_email"] = email
                context["email"] = guest_user_email
                return render_to_response("main/info.html", context_instance=RequestContext(request, context))
        else:
            context["form"] = form
            context["web"] = "guest_user"
            return render_to_response("guest_user/guest_user.html", context_instance=RequestContext(request, context))
    else:
        context["form"] = form
        context["web"] = "guest_user"
        return render_to_response("guest_user/guest_user.html", context_instance=RequestContext(request, context))