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

@ -22,6 +22,7 @@
.other { float: right; margin-right:11em; } .other { float: right; margin-right:11em; }
.score-container { float: right; margin-right:20em;} .score-container { float: right; margin-right:20em;}
.nav { font-size: 120%; padding: 4px 0px;} .nav { font-size: 120%; padding: 4px 0px;}
.matchform { border: 1px solid black; }
</style> </style>
<link href="{% static "assets/css/bootstrap-responsive.css" %}" rel="stylesheet"> <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/jquery.js" %}"></script>
<script src="{% static "js/bootstrap-collapse.js" %}"></script> <script src="{% static "js/bootstrap-collapse.js" %}"></script>
<script src="{% static "js/bootstrap-dropdown.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-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script> <script src="assets/js/bootstrap-alert.js"></script>

View File

@ -1,4 +1,42 @@
{% extends "base.html" %} {% 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 %} {% block content %}
<form class="well form-inline" action="." method="post"> <form class="well form-inline" action="." method="post">
<label>Show Name</label> <label>Show Name</label>
@ -6,105 +44,60 @@
<input type="text" class="span3" name="name" value="{{event.name}}" <input type="text" class="span3" name="name" value="{{event.name}}"
placeholder="RAW/Smackdown/PPV Name"> placeholder="RAW/Smackdown/PPV Name">
<label>Date</label> <label>Date</label>
<input type="text" class="span3" name="date" value="{{event.date}}" <input type="text" class="span3" name="date" value="{{event.date}}" placeholder="YYYY-MM-DD">
placeholder="YYYY-MM-DD"> <div id="all-matches">
{% for match in event.matches %} {% for match in event.matches %}
<!-- match --> <div class="matchform">
<hr> <h4>Match</h4>
<h4>Match #{{forloop.counter}}</h4> <table class="table">
<table class="table"> <tbody>
<tbody> {% for team in match.teams %}
{% for team in match.teams %} <tr>
<tr> <th>team #{{forloop.counter}}</th>
<th>team #{{forloop.counter}}</th> {% for member in team %}
{% for member in team %} <td><input type="text" class="span3"
<td><input type="text" class="span3" {# member-event_id-team_id #}
{# member-event_id-team_id #} name="members-{{forloop.parentloop.parentloop.counter}}-{{forloop.parentloop.counter}}"
name="members-{{forloop.parentloop.parentloop.counter}}-{{forloop.parentloop.counter}}" value="{{member}}">
value="{{member}}"> </td>
</td> {% endfor %}
</tr>
{% endfor %} {% 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 %} {% endfor %}
</tbody> </select>
</table> <label>Winner</label>
<label>Outcome</label> <input type="text" class="span3" name="winner"
<select name="outcome"> value="{{match.winner}}">
{% for val, name in OUTCOMES %} <label>Title</label>
<option value="{{val}}" <select name="title">
{% if match.outcome == val %}selected="selected"{% endif %}> <option value="">(none)</option>
{{name}}</option> {% for val, name in TITLES %}
{% endfor %} <option value="{{val}}"
</select> {% if match.title_at_stake == val %}selected="selected"{% endif %}>
<label>Winner</label> {{name}}</option>
<input type="text" class="span3" name="winner" {% endfor %}
value="{{match.winner}}"> </select>
<label>Title</label> <br>
<select name="title"> <label>Notes</label>
<option value="">(none)</option> <input type="text" class="span6" name="notes"
{% for val, name in TITLES %} value="{{match.notes}}">
<option value="{{val}}" <br>
{% if match.title_at_stake == val %}selected="selected"{% endif %}> <button class="btn">Add Team</button>
{{name}}</option> <button class="btn">Add Member</button>
{% endfor %} <button class="btn btn-danger">Delete Match</button>
</select> </div>
<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 -->
{% endfor %} {% endfor %}
<!-- match clean </div>
<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 %} {% csrf_token %}
<input type="submit" value="Save Event" class="btn btn-primary"/> <input type="submit" value="Save Event" class="btn btn-primary"/>
</div> </div>

View File

@ -50,10 +50,13 @@ def edit_event(request, event):
'teams': [], 'teams': [],
}) })
for k,v in request.POST.iterlists(): for k, team in request.POST.iterlists():
if k.startswith('members'): if k.startswith('members'):
_, match, team = k.split('-') _, match, _ = k.split('-')
edict['matches'][int(match)-1]['teams'].append(v) # 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) event = Event.from_dict(edict)
# score the event for all active leagues # score the event for all active leagues

0
makedb.sh Normal file → Executable file
View File