Example #1
0
def schedule_visitor_training(request):
    if request.method == "POST":
        name = request.POST["training_name"]
        document = Document.objects.get(pk=int(request.POST["document_id"]))
        try:
            description = request.POST["training_description"]
        except:
            description = None

        training = Training(name=name, description=description, training_type=u"告知培训")
        training.document = document
        training.save()

        if request.POST.has_key('group') and request.POST['group']:
            if request.POST.has_key('sub_group') and request.POST['sub_group']:
                group = Group.nonemployee_groups.get(pk=int(request.POST['sub_group']))
            else:
                group = Group.nonemployee_groups.get(pk=int(request.POST['group']))
        else:
            group = Group.nonemployee_groups.root_group()

        if group:
            group.entrance_training = training
            group.save()

        return render_to_response("etraining/admin/schedule_visitor_training_result.html", {}, context_instance=RequestContext(request))
    else:
        documents = Document.objects.all()
        root_group = Group.nonemployee_groups.root_group()
        groups = Group.nonemployee_groups.groups()
        sub_groups = Group.nonemployee_groups.subgroups()
        return render_to_response("etraining/admin/schedule_visitor_training.html", {
            "documents": documents,
            "root_group": root_group,
            "groups": groups,
            "sub_groups": sub_groups,
        }, context_instance=RequestContext(request))
Example #2
0
def schedule_new_employee_training(request):
    if request.method == "POST":
        name = request.POST["training_name"]
        training_type = request.POST["training_type"]
        credits = int(request.POST["credits"])
        pass_criteria = int(request.POST["pass_criteria"])
        question_count = int(request.POST["question_count"])
        exam_type_id = int(request.POST["exam_type"])
        document = Document.objects.get(pk=int(request.POST["document_id"]))
        try:
            description = request.POST["training_description"]
        except:
            description = None

        training = Training(name=name, description=description, training_type=training_type, \
                credits=credits, pass_criteria=pass_criteria, question_count=question_count)
        training.exam_type = QuestionType.objects.get(pk=exam_type_id)
        training.training_date = datetime.date.today() 
        training.document = document
        training.save()

        if request.POST.has_key('group') and request.POST['group']:
            if request.POST.has_key('sub_group') and request.POST['sub_group']:
                group = Group.employee_groups.get(pk=int(request.POST['sub_group']))
            else:
                group = Group.employee_groups.get(pk=int(request.POST['group']))
        else:
            group = Group.employee_groups.root_group()

        if group:
            if training_type == u"班组培训":
                group.banzu_training = training
            elif training_type == u"车间培训":
                group.chejian_training = training
            elif training_type == u"厂级培训":
                group.factory_training = training
            group.save()

        return render_to_response("etraining/admin/schedule_new_employee_training_result.html", {
        }, context_instance=RequestContext(request))
    else:
        documents = Document.objects.all()
        question_types = QuestionType.objects.all()
        root_group = Group.employee_groups.root_group()
        groups = Group.employee_groups.groups()
        sub_groups = Group.employee_groups.subgroups()
        return render_to_response("etraining/admin/schedule_new_employee_training.html", {
            "documents": documents,
            'root_group': root_group,
            "groups": groups,
            "sub_groups": sub_groups,
            "exam_types": question_types,
        }, context_instance=RequestContext(request))
Example #3
0
def schedule_vendor_training(request):
    if request.method == "POST":
        name = request.POST["training_name"]
        project = request.POST["vendor_project"]
        pass_criteria = int(request.POST["pass_criteria"])
        question_count = int(request.POST["question_count"])
        exam_type_id = int(request.POST["exam_type"])
        document = Document.objects.get(pk=int(request.POST["document_id"]))
        try:
            description = request.POST["training_description"]
        except:
            description = None

        training = Training(name=name, description=description, training_type=u"承包商上岗培训", \
            project=project, pass_criteria=pass_criteria, question_count=question_count)
        training.exam_type = QuestionType.objects.get(pk=exam_type_id)
        training.training_date = datetime.date.today() 
        training.document = document
        training.save()

        if request.POST.has_key('group') and request.POST['group']:
            if request.POST.has_key('sub_group') and request.POST['sub_group']:
                group = Group.nonemployee_groups.get(pk=int(request.POST['sub_group']))
            else:
                group = Group.nonemployee_groups.get(pk=int(request.POST['group']))
        else:
            group = Group.nonemployee_groups.root_group()

        if group:
            group.trainings.add(training)
            group.save()

        return render_to_response("etraining/admin/schedule_vendor_training_result.html", {
        }, context_instance=RequestContext(request))
    else:
        documents = Document.objects.all()
        question_types = QuestionType.objects.all()
        sub_groups = Group.nonemployee_groups.vendorgroups()
        return render_to_response("etraining/admin/schedule_vendor_training.html", {
            "documents": documents,
            "sub_groups": sub_groups,
            "exam_types": question_types,
        }, context_instance=RequestContext(request))