本文整理汇总了Python中models.Submission.save方法的典型用法代码示例。如果您正苦于以下问题:Python Submission.save方法的具体用法?Python Submission.save怎么用?Python Submission.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Submission
的用法示例。
在下文中一共展示了Submission.save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submit
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def submit(request):
team = get_team(request.user)
params = dict()
if request.method == 'POST':
form = forms.UploadSubmissionForm(request.POST, request.FILES)
params['form'] = form
if form.is_valid():
submission = Submission(
team=team,
package=request.FILES['file'],
command=request.POST['command'],
)
submission.save()
error = utils.unzip(submission.package.path)
if error:
submission.delete()
params['error'] = error
return render_submit(request, params)
try:
execute_tester(submission)
except Exception as error:
print u'ERROR: Blad wewnetrzny testerki:', error
return my_results(
request, message=_(u'Rozwiązanie zostało wysłane.'))
return render_submit(request, params)
示例2: evaluate
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def evaluate(source_code_name, user_id, task, contest):
extension = get_extension(source_code_name)
command = get_command(extension)
contest_id = contest.contest_id
os.system(command.format(DEST_FOLDER.format(contest_id) + source_code_name, DEST_FOLDER.format(contest_id) + remove_extension(source_code_name)))
source_code_name = remove_extension(source_code_name)
task_id = task.task_id
status = True
for input_file in os.listdir(INPUT_FOLDER.format(contest_id, task_id)):
if get_extension(input_file) == 'zip': continue
user_output = subprocess.check_output(DEST_FOLDER.format(contest_id) + source_code_name + "< " + INPUT_FOLDER.format(contest_id, task_id) + input_file, shell=True)
user_output = re.sub('[\s+]\\n', '\n', user_output)
user_output = user_output.strip()
input_num = input_file.split('_')[1].split('.')[0]
with open(OUTPUT_FOLDER.format(contest_id, task_id) + 'out_' + input_num + '.out') as f:
output = f.read().strip()
print 'worker'
print 'output\n {} \n user_output\n {}'.format(output, user_output)
status = user_output == output
accepted = 'Accepted' if status else 'Wrong Answer'
submission = Submission(accepted, extension, datetime.utcnow(), task.name, user_id, task.task_id, contest.contest_id)
submission.save()
示例3: new_submission
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def new_submission(assignment_id):
assignment = Assignment.query.get(assignment_id)
if request.method == 'POST' and 'file' in request.files:
filename = submissions.save(request.files['file'])
rec = Submission(
filename=filename,
is_official=False,
assignment_id=assignment_id,
user_id=g.user.id)
rec.save()
rec.officialize()
return redirect(url_for('view_assignment', assignment_id=assignment_id))
示例4: save
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def save(request):
form = request.POST
sub = Submission(
user=form["user"],
date=time.strftime("%Y-%m-%d %H:%M:%S"),
language=form["language"],
code=form["code"],
input=form["input"],
)
try:
sub["memory"] = form["memory"]
sub["time"] = form["time"]
finally:
sub.save()
return HttpResponse("OK")
示例5: make_submission
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def make_submission(request):
if request.POST:
print(request.FILES)
submission = Submission()
submission.firstName = request.POST["firstName"]
submission.lastName = request.POST["lastName"]
submission.emailAddress = request.POST["emailAddress"]
submission.category = request.POST["category"]
submission.otherCategoryExplain = request.POST["otherExplain"]
submission.caption = request.POST["caption"]
submission.geoLocation = request.POST["geoLocation"]
submission.photo = request.FILES["photo"]
submission.link = request.POST["link"]
submission.save()
return HttpResponse(str(submission.id))
示例6: upload_file
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def upload_file():
title = request.form['song']
artist = request.form['artist']
picture_file = request.files['file']
photo = Photo()
photo.file.put(picture_file)
photo.save()
track = Track.get_from_spotify(artist, title)
if track is None:
return "No track found!"
track.save()
submission = Submission(photo=photo, track=track)
submission.save()
return redirect('/submissions')
示例7: _save_submission
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def _save_submission(self,request):
def get_type(request):
try:
return FacilityType.objects.get(name=request.POST['type'])
except KeyError:
return None
submit_args = {
'submitter':request.user,
'raw':repr(request.POST),
'name':request.POST.get('name',None),
'address':request.POST.get('address',None),
'type':get_type(request),
'location':get_location(request.POST)
}
submission = Submission(**submit_args)
submission.save()
return submission
示例8: judgeProblem
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def judgeProblem(request, name):
if not request.user.is_authenticated():
return HttpResponse("Please log in to submit your solution.")
language = request.POST.get('language')
sourceCode = request.POST.get('editor')
problem = Problem.objects.get(name=name)
inputString = problem.standardInput
outputString = problem.expectedOutput.replace('\r', '')
result = judge.subprocessJudge(sourceCode, language, inputString, outputString)
resultTuple = status.resultCodeToText(result)
if resultTuple:
s = Submission(user=request.user, problem=problem, result=resultTuple[0],
sourceCode=sourceCode, language=language)
s.save()
resultText = resultTuple[1]
return HttpResponse(resultText)
else:
return HttpResponse("Invalid response. Something went wrong!")
示例9: form_valid
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def form_valid(self, form):
# header = "{email} supplied a form!".format(
# email=form.cleaned_data.get('email_address'))
# message = "\n\nType: {0}".format(form.cleaned_data.get('ticket_type').encode('utf-8'))
# message += "\n\nCourt: {0}".format(form.cleaned_data.get('group_court'))
# message += "\n\ncontact_method: {0}".format(form.cleaned_data.get('contact_method'))
# send_mail(
# subject=header,
# message=message,
# from_email='[email protected]',
# recipient_list=['[email protected]'],
# )
c = Submission()
c.software_download = form.cleaned_data.get('software_download')
c.email_address = form.cleaned_data.get('email_address')
c.submitter_name = form.cleaned_data.get('submitter_name')
c.institution = form.cleaned_data.get('institution')
c.save()
return super(ContactFormView, self).form_valid(form)
示例10: submit
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def submit(request):
team = request.user.team
params = dict()
if request.method == 'POST':
form = UploadSubmissionForm(request.POST, request.FILES)
params['form'] = form
if form.is_valid():
submission = Submission(
team=team,
package=request.FILES['file'],
user=request.user,
)
submission.save()
error = utils.unzip(submission.package.path)
if error:
submission.delete()
params['error'] = error
return render_submit(request, params)
submissions = team.submission_set.all()
if len(submissions) > 2:
for sub in submissions[2:]:
sub.delete()
execute_tester(submission)
messages.add_message(request, messages.INFO, _(u'Rozwiązanie zostało wysłane'))
return redirect('my_results')
#return my_results(
# request, message=_(u'Rozwiązanie zostało wysłane.'))
else:
print form.errors
return render_submit(request, params)
示例11: setUp
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
def setUp(self):
u = User()
u.username = 'reviewerluke'
u.save()
r = Reviewer()
r.user = u
r.name = 'Luke'
r.affiliation = 'COS'
r.email = '[email protected]'
r.bio = 'I love to have fun.'
r.research = 'Fun Facts'
r.website = 'http://lukemarsh.com'
r.osfreviews = 0
r.save()
s = Submission()
s.conference = 'FooCon'
s.title = 'Effects of Foo on Bar'
s.reviewdeadline = datetime.date(2016, 12, 25).isoformat()
s.authorname = 'Foo Bar'
s.authoremail = '[email protected]'
s.status = 'Awaiting review'
s.link = 'http://foobar.org'
s.attachment = '/foo/bar.pdf'
s.save()
s.reviewer.add(r)
s.save()
u2 = User()
u2.username = 'editortom'
u2.save()
ed = Editor()
ed.user = u2
ed.name = 'Tom Heatwole'
ed.email = '[email protected]'
ed.save()
s.editor = ed
s.save()
ev = Evaluation()
ev.status = 'Pending'
ev.progress = 'Received'
ev.premise = 5
ev.research = 6
ev.style = 4
ev.comment = 'This is a comment.'
ev.reviewer = r
ev.submission = s
ev.save()
示例12: sorted
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import save [as 别名]
return string.lower().strip()
if __name__ == '__main__':
for track_photo_name in sorted(os.listdir(PICTURES_FOLDER)):
path = os.path.join(PICTURES_FOLDER, track_photo_name)
# Photo object
photo = Photo()
track_photo = open(path, 'rb')
photo.file.put(track_photo)
photo.save()
# Track object
artist, title = track_photo_name.split('.')[0].split('_')
# Trying to find a previously created track object
track = None
for t in Track.objects:
if clean(t.name) == clean(title) and clean(t.artist_name) == clean(title):
track = t
break
if track is None:
track = Track.get_from_spotify(artist, title)
if track is None:
print "! Couldn't get info for '{} - {}' ; skipping.".format(artist, title)
continue
track.save()
# Submission
submission = Submission(photo=photo, track=track)
submission.save()
print "* '{} - {}' saved in the db".format(artist, title)