当前位置: 首页>>代码示例>>Python>>正文


Python Test.save方法代码示例

本文整理汇总了Python中models.Test.save方法的典型用法代码示例。如果您正苦于以下问题:Python Test.save方法的具体用法?Python Test.save怎么用?Python Test.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Test的用法示例。


在下文中一共展示了Test.save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_path_or_resource

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
    def test_path_or_resource(self):
        c = Client()
        obj = TestModel()
        obj.test = "TESTING"
        obj.save()

        resource = resources1.Test_1_1_Resource()

        list_path = resource.get_resource_list_uri()
        object_path = resource.get_resource_uri(obj)

        result = c._path_or_resource(list_path)
        expected = list_path
        self.assertEqual(result, expected, "Bare path.\nResult:%s\nExpected:%s" % (result, expected))

        result = c._path_or_resource(list_path, obj)
        expected = list_path
        self.assertEqual(result, expected, "Bare path w/obj.\nResult:%s\nExpected:%s" % (result, expected))

        result = c._path_or_resource(resource)
        expected = list_path
        self.assertEqual(result, expected, "Empty resource.\nResult:%s\nExpected:%s" % (result, expected))

        result = c._path_or_resource(resource, obj)
        expected = object_path
        self.assertEqual(result, expected, "Populated resource.\nResult:%s\nExpected:%s" % (result, expected))
开发者ID:thagat,项目名称:django-tastytools,代码行数:28,代码来源:tests.py

示例2: create_test_backup

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
def create_test_backup(request):
    test_obj = json.loads(request.body)
    test = Test()
    #import pdb; pdb.set_trace()
    if request.user.is_authenticated():
        owner = User_Profile.objects.filter(user = request.user)
        test.owner = owner[0]
        test.test_name = test_obj['PRE_TEST']['test_name']
        #test.subject = test_obj['PRE_TEST'].subject
        #test.target_exam = test_obj['PRE_TEST'].target_exam
        #test.topics = test_obj['PRE_TEST'].topics_included
        test.total_time = test_obj['PRE_TEST']['total_time']
        test.pass_criteria = test_obj['PRE_TEST']['pass_criteria']
        test.assoicated_class = Class.objects.get(pk=test_obj['CLASS_INFO'])
        test.save()
        try:
            for item in test_obj['QUESTIONS']:
                question = Question()
                question.question_text = item['question_text']
                question.explanation = item['explanation']
                question.options = json.dumps(item['options'])
                question.hint = item['hint']
                question.difficulty = item['difficulty_level']
                question.points = item['points']
                question.owner = owner[0]
                #question.target_exam = test.target_exam
                #question.subject = test.subject
                #question.topic = item.topic
                question.save()
                test.questions.add(question)
            data = {"status" : "success"}
            return JsonResponse(data)
        except Exception, e:
            raise e
开发者ID:adideshp,项目名称:Tutor,代码行数:36,代码来源:views.py

示例3: save_test

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
def save_test(request):
    print 'POST: ', request.POST
    rule = None
    if request.POST['pattern']:
        rule = Rule(pattern=request.POST['pattern'], replacement=request.POST['replacement'])
        rule.save()
    if rule:
        test = Test(input=request.POST['input'], output=request.POST['output'], rule=rule)
    else:
        test = Test(input=request.POST['input'], output=request.POST['output'])
    test.save()
    response_data = {}

    return HttpResponse(simplejson.dumps(response_data), mimetype="application/json")
开发者ID:timothyclemans,项目名称:InfluenceAPI,代码行数:16,代码来源:views.py

示例4: create_test

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
def create_test(request):
	c=None
	if request.method=='POST':
		testname = request.POST.get('testname','')
		number = request.POST.get('q_number','')
		if 'course' in request.session:
			c = Course.objects.get(name=request.session['course'])
		if c :
			t = Test(name=testname,course = c.id ,question_number=number)
			t.save()
			c.number_test+=1
			c.save()
			return HttpResponseRedirect(reverse('teacher_course',args=(c.name,)))
	else :
		return HttpResponse('wrong method')
开发者ID:CharlesCliff,项目名称:SC,代码行数:17,代码来源:teacherViews.py

示例5: send_presses

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
def send_presses(request, instance_name):
    instance = get_object_or_404(ExperimentInstance, name=instance_name)
    sessions = Session.objects.filter(instance=instance)
    searched_session = 0
    _dict = request.POST.copy()
    for session in sessions:
        tests = Test.objects.filter(session=session)
        if len(tests) < instance.definition.session_length:
            searched_session = session
    new_test = Test(session=searched_session, number=_dict['config'])
    new_test.save()
    del(_dict['config'])
    print _dict
    for i in _dict:
        new_press = Press(test=new_test, key_number=int(i), time=int(_dict[i]), correct=True)
        new_press.save()
    return JsonResponse({'ok': 'ok'})
开发者ID:IridiumOxide,项目名称:1023_alternatives,代码行数:19,代码来源:views.py

示例6: test4031

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
def test4031(request):
    data = json.loads(request.body)
    group = data["group"]
    score = data["score"]
    if group == None or score == None:
        return HttpResponse("Missing fields: group or score.")
    
    test = Test(name = "4031", group = group, score = score)
    test.save()

    text = "Vous avez eu " + str(score) + " nombres.</br>"
    text += "<a href='https://github.com/melodieverroeulst/psy'>Code Source</a>"

    return HttpResponse(json.dumps({
        "title": "Merci!",
        "text": text,
        "html": True,
        "redirectTo": "/"
    }))
开发者ID:melodieverroeulst,项目名称:psy,代码行数:21,代码来源:views.py

示例7: post

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
    def post(self, request):
        form = UploadFileForm(request.POST, request.FILES)
        msg = ''

        if form.is_valid():
            test = Test(
                start_time = convert_time(form.cleaned_data['start']),
                end_time = convert_time(form.cleaned_data['end']),
                author_id = UserProfile.objects.get(user__id=request.user.id),
                time = int(form.cleaned_data['time'])
                )
            test.save()
            try:
                test.room = Room.objects.get(id=form.cleaned_data.get('room'))
            except:
                test.room = None
            finally:
                test.save()
            try:
                self.handle_uploaded_file(test.id, request.FILES['file'])
            except:
                test.delete()
                msg = {'error': 'Wystąpił konflikt terminów. Test nie został dodany.'}
                return render(request, self.template_name, {'form': form, 'msg': msg})

            else:
                test.name = self.get_test_name_from_file(test.id)
                test.save()
            return HttpResponseRedirect(reverse('tests'))
        else:
            msg = {'error': u'Wystąpił błąd podczas ładowania pliku.'}
            form = UploadFileForm()
            return render(request, self.template_name, {'form': form, 'msg': msg})
开发者ID:piotut,项目名称:TestSystem,代码行数:35,代码来源:views.py

示例8: parse

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import save [as 别名]
	def parse(self):
		t = Test(name="aaaaaaaasd", type="yxc")
		t.save()
		return t.name
开发者ID:jakubzitny,项目名称:tndw-controller,代码行数:6,代码来源:test.py


注:本文中的models.Test.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。