本文整理汇总了Python中models.Match.rca方法的典型用法代码示例。如果您正苦于以下问题:Python Match.rca方法的具体用法?Python Match.rca怎么用?Python Match.rca使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Match
的用法示例。
在下文中一共展示了Match.rca方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_matches
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import rca [as 别名]
#.........这里部分代码省略.........
# Loop through match entries
for s in matches:
if s.strip() == '':
continue
try:
# Parse and collect the components
collect = parse_match(s.strip())
pla = collect[0]
plb = collect[1]
sca = int(collect[2][0])
scb = int(collect[2][1])
# Check for !DUP and !MAKE switches if user is logged in
dup_switch = False
make_switch = False
while collect[2][-1][0] == '!':
if collect[2][-1] == '!MAKE':
make_switch = True
elif collect[2][-1] == '!DUP':
dup_switch = True
collect[2] = collect[2][:-1]
if not base['adm']:
make_switch = False
# Check for race overrides
def get_race(lst):
if lst[-1][:2].upper() == 'R:':
r = lst[-1][2:].upper() if lst[-1][2:].upper() in 'PTZR' else None
return r, lst[:-1]
else:
return None, lst
rca, pla = get_race(pla)
rcb, plb = get_race(plb)
# Find players
def get_player(lst, failure, base, make, adm):
#try:
pls = find_player(lst, make=make)
#except Exception as e:
#failure.append(s)
#base['messages'].append(Message('Could not parse: ' + e.message,
#s, Message.ERROR))
#return None
if not pls.exists() and adm:
# Player not found, and user logged in. Add failure message and return None.
failure.append(s)
base['messages'].append(Message(
'Could not find player \'%s\', add !MAKE switch to create.' % ' '.join(lst),
s, Message.ERROR))
return None
if pls.count() > 1 and adm:
# Too many players found, and used logged in. Add failure message and return None.
failure.append(s)
base['messages'].append(NotUniquePlayerMessage(' '.join(lst), pls))
return None
if not pls.exists() or pls.count() > 1:
# Too many or too few players found, and user not logged in. Just return None.
return None
return pls[0]
# If the user is logged in and some players were not found, abort.
pla_obj = get_player(pla, failure, base, make_switch, base['adm'])
if pla_obj == None and base['adm']:
continue
示例2: review
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import rca [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)