basic new event editing, know your role sucka

This commit is contained in:
James Turk 2012-05-28 21:03:25 -04:00
parent 4bbc7c2cd3
commit 7a84097e84
4 changed files with 97 additions and 98 deletions

View File

@ -17,11 +17,12 @@
.match-notes { font-size: 80%; color: #999999; }
.belt-img img { display: block; margin-left: auto; margin-right: auto }
.raw { float: right; margin-right:12em; background-color: #900000;}
.divas { float: right; margin-right:11em; background-color: #900099;}
.divas { float: right; margin-right:11em; background-color: #900099;}
.smackdown { float: right; margin-right:8em; background-color: #003090;}
.other { float: right; margin-right:11em; }
.score-container { float: right; margin-right:20em;}
.nav { font-size: 120%; padding: 4px 0px;}
.matchform { border: 1px solid black; }
</style>
<link href="{% static "assets/css/bootstrap-responsive.css" %}" rel="stylesheet">
@ -78,6 +79,8 @@
<script src="{% static "js/jquery.js" %}"></script>
<script src="{% static "js/bootstrap-collapse.js" %}"></script>
<script src="{% static "js/bootstrap-dropdown.js" %}"></script>
{% block extrascript %} {% endblock %}
<!--
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>

View File

@ -1,4 +1,42 @@
{% extends "base.html" %}
{% block extrascript %}
<script>
$(document).ready(function() {
$('#addMatch').click(function() {
var newform = '<div class="matchform"> \
<h4>Match</h4> \
<table class="table"> <tbody> \
<tr> <th>team #1</th> \
<td><input type="text" class="span3" name="members-MATCH_NUM-1" value=""> </td> \
<td><input type="text" class="span3" name="members-MATCH_NUM-1" value=""> </td> \
</tr> \
<tr> <th>team #2</th> \
<td><input type="text" class="span3" name="members-MATCH_NUM-2" value=""> </td> \
<td><input type="text" class="span3" name="members-MATCH_NUM-2" value=""> </td> \
</tr> \
<tr> <th>team #3</th> \
<td><input type="text" class="span3" name="members-MATCH_NUM-3" value=""> </td> \
<td><input type="text" class="span3" name="members-MATCH_NUM-3" value=""> </td> \
</tr> \
</tbody> </table> \
<label>Outcome</label> <select name="outcome"> \
{% for val, name in OUTCOMES %} <option value="{{val}}">{{name}}</option> {% endfor %} \
</select> \
<label>Winner</label> <input type="text" class="span3" name="winner"> \
<label>Title</label> <select name="title"> <option value="">(none)</option> \
{% for val, name in TITLES %} <option value="{{val}}"> {{name}}</option> {% endfor %} \
</select> <br> \
<label>Notes</label> <input type="text" class="span6" name="notes"> \
<br> <button class="btn">Add Team</button> <button class="btn">Add Member</button> <button class="btn btn-danger">Delete Match</button> </div>';
var num_matches = $('.matchform').length+1;
$('#all-matches').append(newform.replace(/MATCH_NUM/g, num_matches));
return false;
});
});
</script>
{% endblock %}
{% block content %}
<form class="well form-inline" action="." method="post">
<label>Show Name</label>
@ -6,105 +44,60 @@
<input type="text" class="span3" name="name" value="{{event.name}}"
placeholder="RAW/Smackdown/PPV Name">
<label>Date</label>
<input type="text" class="span3" name="date" value="{{event.date}}"
placeholder="YYYY-MM-DD">
<input type="text" class="span3" name="date" value="{{event.date}}" placeholder="YYYY-MM-DD">
<div id="all-matches">
{% for match in event.matches %}
<!-- match -->
<hr>
<h4>Match #{{forloop.counter}}</h4>
<table class="table">
<tbody>
{% for team in match.teams %}
<tr>
<th>team #{{forloop.counter}}</th>
{% for member in team %}
<td><input type="text" class="span3"
{# member-event_id-team_id #}
name="members-{{forloop.parentloop.parentloop.counter}}-{{forloop.parentloop.counter}}"
value="{{member}}">
</td>
<div class="matchform">
<h4>Match</h4>
<table class="table">
<tbody>
{% for team in match.teams %}
<tr>
<th>team #{{forloop.counter}}</th>
{% for member in team %}
<td><input type="text" class="span3"
{# member-event_id-team_id #}
name="members-{{forloop.parentloop.parentloop.counter}}-{{forloop.parentloop.counter}}"
value="{{member}}">
</td>
{% endfor %}
</tr>
{% endfor %}
</tr>
</tbody>
</table>
<label>Outcome</label>
<select name="outcome">
{% for val, name in OUTCOMES %}
<option value="{{val}}"
{% if match.outcome == val %}selected="selected"{% endif %}>
{{name}}</option>
{% endfor %}
</tbody>
</table>
<label>Outcome</label>
<select name="outcome">
{% for val, name in OUTCOMES %}
<option value="{{val}}"
{% if match.outcome == val %}selected="selected"{% endif %}>
{{name}}</option>
{% endfor %}
</select>
<label>Winner</label>
<input type="text" class="span3" name="winner"
value="{{match.winner}}">
<label>Title</label>
<select name="title">
<option value="">(none)</option>
{% for val, name in TITLES %}
<option value="{{val}}"
{% if match.title_at_stake == val %}selected="selected"{% endif %}>
{{name}}</option>
{% endfor %}
</select>
<br>
<label>Notes</label>
<input type="text" class="span6" name="notes"
value="{{match.notes}}">
<br>
<button class="btn">Add Team</button>
<button class="btn">Add Member</button>
<button class="btn btn-danger">Delete Match</button>
<!-- /match -->
</select>
<label>Winner</label>
<input type="text" class="span3" name="winner"
value="{{match.winner}}">
<label>Title</label>
<select name="title">
<option value="">(none)</option>
{% for val, name in TITLES %}
<option value="{{val}}"
{% if match.title_at_stake == val %}selected="selected"{% endif %}>
{{name}}</option>
{% endfor %}
</select>
<br>
<label>Notes</label>
<input type="text" class="span6" name="notes"
value="{{match.notes}}">
<br>
<button class="btn">Add Team</button>
<button class="btn">Add Member</button>
<button class="btn btn-danger">Delete Match</button>
</div>
{% endfor %}
<!-- match clean
<hr>
<h4>Match #2</h4>
<table class="table">
<thead>
<tr>
<th>&nbsp;</th>
<th>member #1</th>
<th>member #2</th>
<th>member #3</th>
</tr>
</thead>
<tbody>
<tr>
<th>team #1</th>
<td><input type="text" class="span3"></td>
<td><input type="text" class="span3"></td>
<td><input type="text" class="span3"></td>
</tr>
<tr>
<th>team #2</th>
<td><input type="text" class="span3"></td>
<td><input type="text" class="span3"></td>
<td><input type="text" class="span3"></td>
</tr>
<tr>
<th>team #3</th>
<td><input type="text" class="span3"></td>
<td><input type="text" class="span3"></td>
<td><input type="text" class="span3"></td>
</tr>
</tbody>
</table>
<label>Winner</label>
<input type="text" class="span3">
<label>Win Type</label>
<select>
<option>Pin</option>
<option>Submission</option>
<option>Disqualification</option>
</select>
<button class="btn">Add Team</button>
<button class="btn">Add Member</button>
<button class="btn btn-danger">Delete Match</button>
/match clean -->
</div>
<div>
<button class="btn">Add Match</button>
<button class="btn" id="addMatch">Add Match</button>
{% csrf_token %}
<input type="submit" value="Save Event" class="btn btn-primary"/>
</div>

View File

@ -50,10 +50,13 @@ def edit_event(request, event):
'teams': [],
})
for k,v in request.POST.iterlists():
for k, team in request.POST.iterlists():
if k.startswith('members'):
_, match, team = k.split('-')
edict['matches'][int(match)-1]['teams'].append(v)
_, match, _ = k.split('-')
# remove empty strings from team
team = [m for m in team if m]
if team:
edict['matches'][int(match)-1]['teams'].append(team)
event = Event.from_dict(edict)
# score the event for all active leagues

0
makedb.sh Normal file → Executable file
View File