本文整理汇总了Python中models.Match.save方法的典型用法代码示例。如果您正苦于以下问题:Python Match.save方法的具体用法?Python Match.save怎么用?Python Match.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Match
的用法示例。
在下文中一共展示了Match.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: match_put
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def match_put(mid, pid):
""" Insert match via Match ID and DotA2 ID """
if not match_check(mid, pid):
query = Match(match_id=mid, player=pid)
query.save()
return True
return False
示例2: confirm_match
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def confirm_match(request, req_id=None):
if request.method == "POST":
if req_id is not None:
try:
sr = ScoreRequest.objects.get(id=req_id)
except:
return HttpResponseRedirect('/welcome/')
form = ConfirmRequestForm(request.POST, instance=sr)
print form
if form.is_valid() and sr.player2.user.username == request.user.username: #and needs to verify player2 is current player lol
form.save()
if int(request.POST['verified']) == 2:
#Save fields into a Match object now
match = Match()
match.player1 = sr.player1
match.player2 = sr.player2
match.wins = sr.wins
match.loss = sr.loss
match.ties = sr.ties
match.tournament = sr.tournament
match.save()
return HttpResponseRedirect('/welcome/')
return HttpResponseRedirect('/welcome/')
else:
print "Only POST requests for now"
return HttpResponseRedirect('/welcome/')
示例3: match
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def match(request, user_id):
user = get_object_or_404(Profile, pk=user_id)
match = Match(date=timezone.now())
match.save()
match.users.add(user, request.user)
match.save()
return HttpResponseRedirect(reverse('meet:match_detail', args=(match.id,)))
示例4: match_new
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def match_new(request):
# print request.body
content = json.loads(request.body)
time = content['match_time']
users = content['users']
game_id = content['game']
match = Match(match_time=time)
match.save()
match.game = Game(id=game_id)
match.users = [user['user_id'] for user in users]
match.save()
return JsonResponse({"success": "ok"})
示例5: get_matches
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def get_matches():
"""
http://wiki.guildwars2.com/wiki/API:1/wvw/matches
"""
for m in api.api_request('wvw/matches')['wvw_matches']:
match = Match(
match_id=m['wvw_match_id'],
red=World.objects.get(world_id=m['red_world_id']),
blue=World.objects.get(world_id=m['blue_world_id']),
green=World.objects.get(world_id=m['green_world_id']),
start_time=m['start_time'],
end_time=m['end_time'])
match.save()
return Match.objects.all()
示例6: run
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def run(self, message, keyword, answer, **kwargs):
if message.sender not in SUPERVISORS:
logger.warning('User %s triggered training but rejected', message.sender)
return None
if keyword in DIALOGUES:
DIALOGUES[keyword].append(answer)
else:
DIALOGUES[keyword] = [answer]
match = Match(keyword=keyword, answer=answer)
match.save()
print(keyword, answer)
return random.choice((
'好的~',
'(筆記)',
'學會了這句,我就可以去選總統了!',
))
示例7: match_post
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def match_post(request):
"""
Form posted to this url, creates the match and returns a link to send the next one to
"""
if request.method != 'POST':
return HttpResponseRedirect("http://keen.to/match")
chosen = request.POST.getlist('chosen[]')
email = request.POST.get('email')
suggested = []
for c in chosen:
if c not in options:
suggested.append(c)
new_match = Match(email_1 = email, chose_1 = chosen, views=[get_client_ip(request)], suggested = suggested)
new_match.save()
id_ = new_match.id
hasher = hashlib.sha1(str(id_))
hash_ = base64.urlsafe_b64encode(hasher.digest())[:5]
new_match.hash = hash_
new_match.save()
#Email them the number?
return render_to_response('match_post.html', {'link' : 'http://keen.to/match/' + hash_, 'hash' : hash_, 'showform' : True}, context_instance=RequestContext(request))
示例8: new
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def new():
c1=Category(cat="Football")
c1.save()
c2=Category(cat="Basketball")
c2.save()
c3=Category(cat="Hockey")
c3.save()
c4=Category(cat="Soccer")
c4.save()
c5=Category(cat="Random")
c5.save()
m1=Match(match="Washington v Dallas",cat=c1)
m1.save()
m2=Match(match="Wisconsin v Michigan",cat=c1)
m2.save()
m3=Match(match="Spartak v Celtic",cat=c4)
m3.save()
m4=Match(match="Arsenal v Chelsea",cat=c4)
m4.save()
m5=Match(match="Caps v Flyers",cat=c3)
m5.save()
o1=Offer(offer="Dallas",match=m1,odds=2.3)
o1.save()
o2=Offer(offer="Washington",match=m1,odds=5)
o2.save()
o3=Offer(offer="Soccer Riot",match=m3,odds=5)
o3.save()
u1 = User.objects.create_user('matt', '[email protected]', 'p')
u1.save()
u2=User.objects.create_user('mike', '[email protected]', 'p')
u2.save()
u3=User.objects.create_user('dan', '[email protected]', 'p')
u3.save()
u4=User.objects.create_user('scott', '[email protected]', 'p')
u4.save()
u5=User.objects.create_user('nick', '[email protected]', 'p')
u5.save()
示例9: start_tournament
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def start_tournament(tournament_id):
"""
Starts a tournament
:param tournament_id: Id of a tournament to start
:return: True if success, False otherwise
"""
try:
the_tournament = Tournament.objects.get(id=tournament_id)
t_users = [x.user for x in Registration.objects.filter(tournament=the_tournament)]
except ObjectDoesNotExist:
return False
if len(t_users) < the_tournament.max_participants:
## Add free slots
pass
for i in range(the_tournament.max_participants - 1):
m = Match()
m.tournament = the_tournament
m.code = i
if i < the_tournament.max_participants / 2:
m.left_user = t_users[i * 2]
m.right_user = t_users[i * 2 + 1]
m.save()
# Let the game begin!
the_tournament.has_started = True
the_tournament.save()
for reg in Registration.objects.filter(tournament=the_tournament):
reg.delete()
return True
示例10: get_match
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def get_match(request, region=None, match_id=None):
region = 'na' if region is None else region
api_key = request.body if request.body else API_KEY
proceed = update_rate_limits(api_key, region)
if not proceed:
return HttpResponse("Rate limit exceeded. Try again in a few seconds.", status=429)
if match_id is not None:
try:
match = Match.objects.filter(match_id=match_id)[0]
except:
match = Match(match_id=match_id, region=region)
match.save()
else:
try:
match_priorities = MatchList.objects.filter(match_used=False, region=region).values('match_id').annotate(priority_sum=Sum('match_priority')).order_by('-priority_sum')[0]
# if summoners have a higher priority than matches, then input a summoner's champion mastery and matchlist
if Summoners.objects.filter(summoner_used=False, region=region).exists():
if Summoners.objects.filter(summoner_used=False, region=region).order_by('-summoner_priority')[0].summoner_priority > 2 *match_priorities['priority_sum']:
return get_matchlist_and_champion_mastery(request, region, None)
match = Match.objects.get(pk=match_priorities['match_id'])
match_id = match.match_id
except:
return get_matchlist_and_champion_mastery(request, region, None)
url = urllib2.Request("https://{0}.api.pvp.net/api/lol/{0}/v2.2/match/{1}?api_key={2}".format(region, match_id, api_key))
try:
response = urllib2.urlopen(url)
except urllib2.HTTPError as e:
if e.code == 429:
num_seconds = 5
if "Retry-After" in e.headers:
num_seconds = int(e.headers.get("Retry-After"))
timers = RateLimitTimer.objects.filter(region=region)
try:
timer = timers[0]
except:
timer=RateLimitTimer(region=region)
timer.next_check_time = datetime.utcnow() + timedelta(seconds=num_seconds)
timer.save()
return HttpResponse("Rate limit exceeded. Try again in " + num_seconds + " seconds.", status=429)
elif e.code == 404: #not sure why it gets this sometimes (perhaps match is too recent?)
matchlists = MatchList.objects.filter(match_id=match, region=region)
for matchlist in matchlists:
matchlist.match_used = True
matchlist.save()
return get_matchlist_and_champion_mastery(request, region, None)
else:
return HttpResponse(status=e.code)
except urllib2.URLError:
return HttpResponse("Error connecting to the Riot API. Try again soon.", status=504)
data = json.load(response)
matchlist_tuples = {}
for i, participant in enumerate(data['participants']):
index = i % 5
if participant.get('teamId', 'N/A') == 200:
index += 5
matchlist_tuples[participant.get('participantId', 'N/A')] = (index, MatchList(match_id=match, region=region, match_used=1, champion_id=participant.get('championId', 'N/A'), lane=participant.get('timeline', 'N/A').get('lane', 'N/A'), role=participant.get('timeline', 'N/A').get('role', 'N/A'), queue=data.get('queueType', 'N/A')))
summoners = []
num_summoners_used = 0
for participant in data['participantIdentities']:
participant_id = participant.get('participantId', 'N/A')
try:
summoner_id = participant.get('player', 'N/A').get('summonerId', 'N/A')
except:
continue
if not Summoners.objects.filter(summoner_id=summoner_id, region=region).exists():
summoner = Summoners(summoner_id=summoner_id, region=region, summoner_priority=0)
summoner.save()
summoners.append(summoner)
else:
summoner = Summoners.objects.filter(summoner_id=summoner_id, region=region)[0]
if not summoner.summoner_used:
summoners.append(summoner)
else:
num_summoners_used += 1
matchlist_tuples[participant_id][1].summoner_id = summoner
try:
matchlist = MatchList.objects.filter(summoner_id=summoner, match_id=match, region=region)[0]
matchlist.match_used = True
except:
matchlist = matchlist_tuples[participant_id][1]
matchlist.save()
setattr(match, 'summoner_'+str(matchlist_tuples[participant_id][0]), summoner)
for summoner in summoners:
summoner.summoner_priority += num_summoners_used
summoner.save()
for team in data['teams']:
if team.get('teamId', 'N/A') == 200:
match.winner = team.get('winner', 'N/A')
match.save()
return redirect('home')
示例11: addmatch
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def addmatch(request,idfixture):
try:
usuario = UserProfile.objects.get(user=request.user)
except Exception:
usuario = None
if request.user.is_anonymous():
return HttpResponseRedirect('/login')
if usuario.userType=='PR':
try:
publish_one = Publicity.objects.all().order_by('?').first()
except Exception:
publish_one = False
try:
publish_second = Publicity.objects.all().exclude(id=publish_one.id).order_by('?').last()
except Exception:
publish_second = False
if request.POST:
mform = MatchForm(request.POST)
fixture_id = request.GET.get('idfixture')
if mform.is_valid(): #if the information in the form its correct
#First, save the default User model provided by Django
match = Match(
day=mform.cleaned_data['day'],
hour=mform.cleaned_data['hour'],
minutes=mform.cleaned_data['minutes'],
teamlocal=mform.cleaned_data['teamlocal'],
teamVisitant=mform.cleaned_data['teamVisitant'],
fixture = Fixture.objects.get(id=idfixture),
court = mform.cleaned_data['court']
)
try:
f = Fixture.objects.get(id=idfixture)
except Exception, e:
message = """
Oops!!!, ha ocurrido un inconveniente, el fixture al que intenta agregar un
partido aún no ha sido creado.Si el inconveniente persiste contactese.
"""
sendmail = True
return render_to_response('404.html',{'message':message,'sendmail':sendmail})
if mform.cleaned_data['day']<f.date and mform.cleaned_data['teamlocal']!=mform.cleaned_data['teamVisitant']:
mform = MatchForm()
fixture_id = Fixture.objects.get(id=idfixture)
message_day_incorrect = "La fecha debe ser mayor o igual a "+str(object=f.date)
return render_to_response('matches/addmatch.html', {'publish_one':publish_one,'publish_second':publish_second,'mform': mform, 'fixture_id':fixture_id,'message_day_incorrect':message_day_incorrect}, RequestContext(request, {}))
if mform.cleaned_data['teamlocal']==mform.cleaned_data['teamVisitant'] and mform.cleaned_data['day']>=f.date:
mform = MatchForm()
fixture_id = Fixture.objects.get(id=idfixture)
message_teams_incorrect = "el equipo local no pude ser igual al visitante"
return render_to_response('matches/addmatch.html', {'publish_one':publish_one,'publish_second':publish_second,'mform': mform, 'fixture_id':fixture_id,'message_teams_incorrect':message_teams_incorrect}, RequestContext(request, {}))
if mform.cleaned_data['teamlocal']==mform.cleaned_data['teamVisitant'] and mform.cleaned_data['day']<f.date:
mform = MatchForm()
fixture_id = Fixture.objects.get(id=idfixture)
message_teams_incorrect = "el equipo local no pude ser igual al visitante"
message_day_incorrect = "La fecha debe ser mayor o igual a "+str(object=f.date)
return render_to_response('matches/addmatch.html', {'publish_one':publish_one,'publish_second':publish_second,'mform': mform, 'fixture_id':fixture_id,'message_teams_incorrect':message_teams_incorrect, 'message_day_incorrect':message_day_incorrect}, RequestContext(request, {}))
if usuario.userType == 'PR':
match.save()
else:
return HttpResponseRedirect('/addmatch/'+str(object=idfixture))
return HttpResponseRedirect('/fixtures')
else:
mform = MatchForm()
#la sig variable y el if verifica si el fixture es propiedad del usuario logueado
verify_fixture = Fixture.objects.filter(id=idfixture ,tournament=Tournament.objects.filter(complex=Complex.objects.filter(user=request.user))).count()
if verify_fixture == 0:
message = """
Oops!!!, ha ocurrido un inconveniente, el fixture al que intenta agregar un
partido aún no ha sido creado o no es de su propiedad.Si el inconveniente persiste contactese.
"""
sendmail = True
return render_to_response('404.html',{'message':message,'sendmail':sendmail})
else:
fixture_id = Fixture.objects.get(id=idfixture)
return render_to_response('matches/addmatch.html', {'publish_one':publish_one,'publish_second':publish_second,'mform': mform, 'fixture_id':fixture_id}, RequestContext(request, {}))
示例12: start_tournament
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def start_tournament(self, request, queryset):
# For each tournament that we are starting...
for tournament in queryset:
# Grab all of the teams that are in a specific tournament
teams_q = Team.objects.filter(tournaments__id=tournament.id)
teams = []
for tq in teams_q:
teams.append(tq)
# Randomize the teams!
random.shuffle(teams)
round_num = 1
# Create initial matches
team_offset = 0
while (len(teams) - team_offset) > 0:
# If we have enough teams for a match...
if (len(teams) - team_offset) >= tournament.teams_per_match:
# Create a match
match = Match()
match.round = round_num
match.tournament = tournament
# Sync back to the DB before adding teams
match.save()
match.teams
for _ in xrange(tournament.teams_per_match):
#while len(match.teams) < tournament.teams_per_match:
match.teams.add(teams[team_offset])
team_offset += 1
match.save()
else:
# Since we have teams left, but not enough for a match
# We create dud matches with seed teams
match = Match()
match.round = round_num
match.tournament = tournament
match.save()
if teams[team_offset]:
match.teams.add(teams[team_offset])
match.teams.winner = teams[team_offset]
team_offset += 1
# Create each round's tournaments
done = False
while not done:
matches = Match.objects.filter(round_num=round_num, tournament=tournament.id)
if len(matches) > 0:
round_num += 1
new_matches = (len(matches) / tournament.teams_per_match)
new_seeds = (len(matches) % tournament.teams_per_match)
if new_matches == 1 and new_seeds == 0:
done = True
old_matches = []
for match in matches:
old_matches.append(match)
for _ in xrange(new_matches):
new_match = Match()
new_match.round = round_num
new_match.tournament = tournament
new_match.save()
for _ in xrange(tournament.teams_per_match):
t_match = old_matches.pop()
t_match.child = new_match
t_match.save()
while new_seeds >= tournament.teams_per_match:
new_match = Match()
new_match.round = round_num
new_match.tournament = tournament
new_match.save()
for _ in xrange(tournament.teams_per_match):
t_match = old_matches.pop()
t_match.child = new_match
t_match.save()
new_seeds -= tournament.teams_per_match
for _ in xrange(new_seeds):
new_match = Match()
new_match.round = round_num
new_match.tournament = tournament
new_match.save()
t_match = old_matches.pop()
t_match.child = new_match
new_match.save()
t_match.save()
else:
done = True
示例13: submit_make
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def submit_make(request):
if os.environ.get("TEST", None):
request.session["userId"] = request.GET["userId"]
try:
userId = request.POST["userId"]
user = User.objects.get(openId=userId)
now = basic_tools.getNow()
match = Match(title=request.POST["match_name"],description=request.POST["comment"],createTime=now,startTime=basic_tools.DateToInt("%s:00:00" % request.POST["begintime"][:13]),endTime=basic_tools.DateToInt("%s:00:00" % request.POST["endtime"][:13]),creator=user)
match.save()
tags = []
tag = request.POST["tags"]
if not tag == "":
item = MTag.objects.filter(name=tag)
if len(item) == 0:
item = MTag(name=tag)
item.save()
else:
item = item[0]
if not item.matchs.filter(id=match.id).exists():
tags.append(tag)
item.matchs.add(match)
i = 0
while ("tag%d" % i) in request.POST:
tag = request.POST["tag%d" % i]
i += 1
if not tag == "":
item = MTag.objects.filter(name=tag)
if len(item) == 0:
item = MTag(name=tag)
item.save()
else:
item = item[0]
if not item.matchs.filter(id=match.id).exists():
tags.append(tag)
item.matchs.add(match)
match.user_members.add(user)
team = user.user_team_members.get(type=0)
match.members.add(team)
prefix = os.environ.get("WRIST_HOME")
path = "/media/match/"
if not os.path.exists(prefix+path):
os.mkdir(prefix+path)
if "image" in request.FILES:
file = request.FILES["image"]
file_name = "%s%s_%s_%s" % (path, match.title.encode("utf-8"), str(now), file.name.encode("utf-8"))
des = open(prefix+file_name, "wb")
for chunk in file.chunks():
des.write(chunk)
des.close()
else:
file_name = tools.getDefaultImageByTag(tags)
match.image = file_name
match.save()
i = 0
while ("friend%d" % i) in request.POST:
tools.sendInvite(user, plan.id, request.POST["friend%d" % i], 0)
i += 1
i = 0
while ("opponent%d" % i) in request.POST:
tools.sendInvite(user, plan.id, request.POST["opponent%d" % i], 1)
i += 1
return HttpResponseRedirect("/match/redirect/profile?page=3&id=%d" % match.id)
except:
return HttpResponse("/static/404.html")
示例14: add_matches
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [as 别名]
def add_matches(request):
# This view is the default redirect for login requests
if 'username' in request.POST and 'password' in request.POST:
user = authenticate(username=request.POST['username'], password=request.POST['password'])
if user != None and user.is_active:
login(request, user)
base = base_ctx('Submit', 'Matches', request)
add_login_message(base, extra='Submitted results will be pending review before inclusion.')
# If the user is logged in, the template needs a username and a list of event objects
if base['adm']:
base['events'] = Event.objects.filter(closed=False, rgt=F('lft')+1).order_by('lft')
if 'matches' in request.POST:
# Collect various information from the form
try:
event = request.POST['event'].strip()
except:
event = None
date = request.POST['date']
matches = request.POST['matches'].splitlines()
offline = not (request.POST['type'] != 'offline')
game = request.POST['game']
if game not in ['WoL', 'HotS']:
game = 'WoL'
base['game'] = game
base['type'] = 'offline' if offline else 'online'
base['matches'] = '\n'.join(matches)
base['date'] = date
base['event'] = event
# Get event object. If not admin, an exception will be thrown and eventobj = None.
try:
eventobj = Event.objects.get(id=int(request.POST['eobj']))
if eventobj.id == 2:
eventobj = None
except:
eventobj = None
if eventobj is not None:
base['eobj'] = eventobj.id
# Get extra data needed if not admin.
try:
source = request.POST['source']
contact = request.POST['contact']
notes = request.POST['notes']
base['source'] = source
base['contact'] = contact
base['notes'] = notes
except:
pass
# Check various requirements for non-admins
if not base['adm'] and len(matches) > 100:
base['messages'].append(Message('Please do not submit more than 100 results at a time.',
'Too many entries', Message.ERROR))
base.update(csrf(request))
return render_to_response('add.html', base)
if not base['adm'] and source.strip() == '':
base['messages'].append(Message('Please include a source.', 'Source missing', Message.ERROR))
base.update(csrf(request))
return render_to_response('add.html', base)
# If not admin, make a PreMatchGroup.
if not base['adm']:
pmgroup = PreMatchGroup(date=date, event=event, source=source, contact=contact, notes=notes,\
game=game, offline=offline)
pmgroup.save()
# Lists of successes and failures
success = []
failure = []
# 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]
#.........这里部分代码省略.........
示例15: review
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import save [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)