示例#1
0
def step(context, practice_uid, course_name, filename):
    course = Course.objects.get(name=course_name)
    practice = Practice.objects.get(uid=practice_uid, course=course)
    practiceFile = PracticeFile()
    practiceFile.name = filename
    practiceFile.file = "data/file.pdf"
    practiceFile.practice = practice
    practiceFile.save()
示例#2
0
def step(context, practice_uid, course_name, filename):
    course = Course.objects.get(name=course_name)
    practice = Practice.objects.get(uid=practice_uid, course=course)
    practiceFile = PracticeFile()
    practiceFile.name = filename
    practiceFile.file = "data/file.pdf"
    practiceFile.practice = practice
    practiceFile.save()
示例#3
0
文件: practice.py 项目: nicopaez/seal
def practicefilelist(request, idcourse, idpractice):
    if(len(request.user.teacher_set.all()) > 0): # if an authenticated user "accidentally" access this section, he doesn't get an exception
        practice = Practice.objects.get(pk = idpractice)
        practiceFiles = practice.get_practice_file()
        if (request.method == 'POST'):
            practice_file_instance = PracticeFile(practice=practice)
            form = PracticeFileForm(request.POST, request.FILES, instance=practice_file_instance)
            if (form.is_valid()):
                form_edit = form.save(commit=False)
                form_edit.save()
                return HttpResponseRedirect(PATHFILEOK % (str(idcourse), str(practice.pk)))
        else:
            form = PracticeFileForm()
        return render(request, 'practice/uploadFile.html', {'form': form, 'idcourse':idcourse, 'namepractice':practice.uid, 'practiceFiles': practiceFiles})
    else:
        return HTTP_401_UNAUTHORIZED_RESPONSE
示例#4
0
def step(context, practice_name, practice_file_id):
    practice_path = managepath.get_instance().get_practice_path()
    if not os.path.exists(practice_path):
        os.makedirs(name=practice_path)
    practice_filename = "practice_no_text_file.pdf"
    practice_filepath = os.path.join(practice_path, practice_filename)
    with open(practice_filepath, 'w') as test_file:
        lines = [
            "first line\n", "second line\n", "third line\n", "fourth line\n",
            "fifth line\n"
        ]
        test_file.writelines(lines)
    practice = Practice.objects.filter(uid=practice_name)[0]
    practice_file = PracticeFile()
    practice_file.pk = practice_file_id
    practice_file.name = "Prueba"
    practice_file.file = practice_filepath
    practice_file.practice = practice
    practice_file.save()
示例#5
0
def step(context, practice_name, practice_file_id):
    practice_path = managepath.get_instance().get_practice_path()
    if not os.path.exists(practice_path):
        os.makedirs(name=practice_path)
    practice_filename = "practice_no_text_file.pdf"
    practice_filepath = os.path.join(practice_path, practice_filename)
    with open(practice_filepath, 'w') as test_file:
        lines = ["first line\n",
                 "second line\n",
                 "third line\n",
                 "fourth line\n",
                 "fifth line\n"]
        test_file.writelines(lines)
    practice = Practice.objects.filter(uid=practice_name)[0]
    practice_file = PracticeFile()
    practice_file.pk = practice_file_id
    practice_file.name = "Prueba"
    practice_file.file = practice_filepath
    practice_file.practice = practice
    practice_file.save()