本文整理汇总了Python中models.Match.submitter方法的典型用法代码示例。如果您正苦于以下问题:Python Match.submitter方法的具体用法?Python Match.submitter怎么用?Python Match.submitter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Match
的用法示例。
在下文中一共展示了Match.submitter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_matches
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import submitter [as 别名]
#.........这里部分代码省略.........
n = find_duplicates(pla_obj, plb_obj, sca, scb, date)
if n > 0 and not dup_switch:
failure.append(s)
base['messages'].append(Message(
'%i possible duplicate(s) found, add !DUP switch to force.' % n,
s, Message.ERROR))
continue
# If the user is not logged in, we now have enough information to create a prematch.
if not base['adm']:
pm = PreMatch(group=pmgroup, sca=sca, scb=scb, pla=pla_obj, plb=plb_obj,\
pla_string=' '.join(pla), plb_string=' '.join(plb), date=pmgroup.date)
if rca:
pm.rca = rca
elif pla_obj:
pm.rca = pla_obj.race
else:
pm.rca = None
if rcb:
pm.rcb = rcb
elif plb_obj:
pm.rcb = plb_obj.race
else:
pm.rcb = None
pm.save()
success.append(pm)
continue
# Abort if race information is incorrect
if pla_obj.race == 'S' and rca == None:
failure.append(s)
base['messages'].append(Message(
'%s is Random or Switcher, need race information.' % pla_obj.tag,
s, Message.ERROR))
continue
if plb_obj.race == 'S' and rcb == None:
failure.append(s)
base['messages'].append(Message(
'%s is Random or Switcher, need race information.' % plb_obj.tag,
s, Message.ERROR))
continue
# Add match
m = Match()
m.pla = pla_obj
m.plb = plb_obj
m.sca = sca
m.scb = scb
m.rca = pla_obj.race if rca == None else rca
m.rcb = plb_obj.race if rcb == None else rcb
m.date = date
m.submitter = request.user
m.set_period()
m.eventobj = eventobj
m.offline = offline
m.game = game
m.save()
success.append(m)
except Exception as e:
failure.append(s)
base['messages'].append(Message('Could not parse: ' + e.message, s, Message.ERROR))
continue
success = display_matches(success, messages=False)
if len(success) > 0:
base['messages'].append(Message('Added %i match(es).' % len(success), type=Message.SUCCESS))
base.update({'matches': '\n'.join(failure), 'success': success})
elif 'eventid' in request.GET:
try:
event = Event.objects.get(id=int(request.GET['eventid']))
if event.closed:
event.closed = False
event.save()
base['messages'].append(Message('Reopened \'%s\'.' % event.fullname, type=Message.SUCCESS))
base['eobj'] = event.id
except:
base['messages'].append(Message('Couldn\'t find event ID %s.' % request.GET['eventid'],
type=Message.ERROR))
try:
if base['adm'] and request.POST['action'] == 'Add and close event' and eventobj is not None:
if len(failure) == 0:
eventobj.close()
base['messages'].append(Message('Event \'%s\' closed.' % eventobj.fullname,
type=Message.SUCCESS))
else:
base['messages'].append(Message('Event \'%s\' was NOT closed.' % eventobj.fullname,
type=Message.WARNING))
except:
pass
base.update(csrf(request))
return render_to_response('add.html', base)
示例2: review
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import submitter [as 别名]
def review(request):
base = base_ctx('Submit', 'Review', request)
if not base['adm']:
base.update(csrf(request))
return render_to_response('login.html', base)
add_login_message(base)
base['events'] = Event.objects.filter(closed=False, rgt=F('lft')+1).order_by('lft')
if 'act' in request.POST and base['adm'] == True:
if int(request.POST['eobj']) != 2:
eobj = Event.objects.get(id=int(request.POST['eobj']))
base['eobj'] = eobj.id
delete = True if request.POST['act'] == 'reject' else False
success = []
ndel = 0
for key in sorted(request.POST.keys()):
if request.POST[key] != 'y':
continue
if key[0:6] == 'match-':
pm = PreMatch.objects.get(id=int(key.split('-')[-1]))
if delete:
group = pm.group
pm.delete()
if not group.prematch_set.all().exists():
group.delete()
ndel += 1
continue
if pm.pla == None:
pm.pla_string = request.POST['match-%i-pla' % pm.id]
if pm.plb == None:
pm.plb_string = request.POST['match-%i-plb' % pm.id]
if pm.pla == None or pm.plb == None:
review_treat_players(pm, base)
if pm.pla and not pm.rca:
pm.pla = None
if pm.plb and not pm.rcb:
pm.plb = None
pm.save()
if pm.pla and pm.plb and pm.rca and pm.rcb:
m = Match()
m.pla = pm.pla
m.plb = pm.plb
m.sca = pm.sca
m.scb = pm.scb
m.rca = pm.rca
m.rcb = pm.rcb
if request.POST['date'].strip() == '':
m.date = pm.group.date
else:
m.date = request.POST['date']
m.event = pm.group.event
m.eventobj = eobj
m.submitter = request.user
m.set_period()
m.offline = pm.group.offline
m.game = pm.group.game
m.save()
success.append(m)
group = pm.group
pm.delete()
if not group.prematch_set.all().exists():
group.delete()
base['success'] = display_matches(success, messages=False)
if len(success) > 0:
base['messages'].append(Message('Approved %i match(es).' % len(success), type=Message.SUCCESS))
if ndel > 0:
base['messages'].append(Message('Rejected %i match(es).' % ndel, type=Message.SUCCESS))
groups = PreMatchGroup.objects.filter(prematch__isnull=False)\
.select_related('prematch').order_by('id', 'event').distinct()
for g in groups:
g.prematches = display_matches(g.prematch_set.all(), messages=False)
base['groups'] = groups
base.update(csrf(request))
return render_to_response('review.html', base)