コード例 #1
0
def create_link_student_file(student_data, subject, file_type, import_errors_link, user_create,
                             user_link):
    if file_type == "text/xml":
        data_form = StudentService.get_form_data_xml(student_data)
    else:
        data_form = StudentService.get_form_data_csv(student_data)

    form_student = UserEditForm(data=data_form)

    if form_student.is_valid():
        student = StudentService.create(form_student)
        StudentService.save(student)
        password = id_generator()
        UserService.save_password(student, password)
        user_create[student] = password
        student.asignaturas.add(subject)
    else:
        fullname = form_student.data['last_name'] + ", " + form_student.data['first_name']
        username = form_student.data['user']
        user = UserService.find_by_username(username)
        if user:
            student = Alumno.objects.get(id=user.id)
            if student:
                student.asignaturas.add(subject)
                user_link.append(student)
            else:
                import_errors_link.append(_("Student") + ": " + fullname + " - " + form_student.data['dni'])
        else:
            import_errors_link.append(_("Student") + ": " + fullname + " - " + form_student.data['dni'])
コード例 #2
0
def create_user(request):
    if request.POST:
        form = UserEditForm(request.POST)
        if form.is_valid():

            if form.cleaned_data["type"] == "st":
                # Is student
                user = StudentService.create(form)
                StudentService.save(user)
            elif form.cleaned_data["type"] == "le":
                # Is lecturer
                user = LecturerService.create(form)
                LecturerService.save(user)
            password = id_generator()
            UserService.save_password(user, password)
            user_create = {user: password}
            EmailService.send_email_create_user(user_create, request)
            messages.success(request, _("Action completed successfully"))
            return HttpResponseRedirect("/admin/user/create")
    else:
        data = {}
        form = UserEditForm(initial=data)

    template_name = "user/edit.html"
    template_data = {"form": form}
    return render_to_response(template_name, template_data, context_instance=RequestContext(request))
コード例 #3
0
def create_user(request):
    if request.POST:
        form = UserEditForm(request.POST)
        if form.is_valid():

            if form.cleaned_data['type'] == 'st':
                # Is student
                user = StudentService.create(form)
                StudentService.save(user)
            elif form.cleaned_data['type'] == 'le':
                # Is lecturer
                user = LecturerService.create(form)
                LecturerService.save(user)
            password = id_generator()
            UserService.save_password(user, password)
            user_create = {user: password}
            EmailService.send_email_create_user(user_create, request)
            messages.success(request, _("Action completed successfully"))
            return HttpResponseRedirect("/admin/user/create")
    else:
        data = {}
        form = UserEditForm(initial=data)

    template_name = 'user/edit.html'
    template_data = {"form": form}
    return render_to_response(template_name,
                              template_data,
                              context_instance=RequestContext(request))
コード例 #4
0
def create_link_student_file(student_data, subject, file_type,
                             import_errors_link, user_create, user_link):
    if file_type == "text/xml":
        data_form = StudentService.get_form_data_xml(student_data)
    else:
        data_form = StudentService.get_form_data_csv(student_data)

    form_student = UserEditForm(data=data_form)

    if form_student.is_valid():
        student = StudentService.create(form_student)
        StudentService.save(student)
        password = id_generator()
        UserService.save_password(student, password)
        user_create[student] = password
        student.asignaturas.add(subject)
    else:
        fullname = form_student.data['last_name'] + ", " + form_student.data[
            'first_name']
        username = form_student.data['user']
        user = UserService.find_by_username(username)
        if user:
            student = Alumno.objects.get(id=user.id)
            if student:
                student.asignaturas.add(subject)
                user_link.append(student)
            else:
                import_errors_link.append(
                    _("Student") + ": " + fullname + " - " +
                    form_student.data['dni'])
        else:
            import_errors_link.append(
                _("Student") + ": " + fullname + " - " +
                form_student.data['dni'])
コード例 #5
0
def create_student_file(data_form, import_errors_create, user_create):

    form_student = UserEditForm(data=data_form)
    if form_student.is_valid():
        student = StudentService.create(form_student)
        StudentService.save(student)
        password = id_generator()
        UserService.save_password(student, password)
        user_create[student] = password
    else:
        fullname = form_student.data["last_name"] + ", " + form_student.data["first_name"]
        import_errors_create.append(_("Student") + ": " + fullname + " - " + form_student.data["dni"])
コード例 #6
0
def create_student_file(data_form, import_errors_create, user_create):

    form_student = UserEditForm(data=data_form)
    if form_student.is_valid():
        student = StudentService.create(form_student)
        StudentService.save(student)
        password = id_generator()
        UserService.save_password(student, password)
        user_create[student] = password
    else:
        fullname = form_student.data['last_name'] + ", " + form_student.data[
            'first_name']
        import_errors_create.append(
            _("Student") + ": " + fullname + " - " + form_student.data['dni'])