a bit more work on editing

This commit is contained in:
James Turk 2012-06-25 22:54:00 -04:00
parent b3e29bb2a7
commit e150e0ca8a
2 changed files with 19 additions and 4 deletions

View File

@ -2,6 +2,12 @@
{% block extrascript %} {% block extrascript %}
<script> <script>
var stars = [
{% for star in stars %}
{'id': '{{star.id}}', 'text': '{{star}}'}{% if not forloop.last %}, {% endif %}
{% endfor %}
];
$(document).ready(function() { $(document).ready(function() {
$('#addMatch').click(function() { $('#addMatch').click(function() {
var newform = '<div class="matchform"> \ var newform = '<div class="matchform"> \
@ -28,12 +34,21 @@
{% for val, name in TITLES %} <option value="{{val}}"> {{name}}</option> {% endfor %} \ {% for val, name in TITLES %} <option value="{{val}}"> {{name}}</option> {% endfor %} \
</select> <br> \ </select> <br> \
<label>Notes</label> <input type="text" class="span6" name="notes"> \ <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>'; <br> <button class="btn">Add Team</button> <button class="btn">Add Member</button> <button class="btn btn-danger delete-btn">Delete Match</button> </div>';
var num_matches = $('.matchform').length+1; var num_matches = $('.matchform').length+1;
$('#all-matches').append(newform.replace(/MATCH_NUM/g, num_matches)); $('#all-matches').append(newform.replace(/MATCH_NUM/g, num_matches));
register_handlers();
return false; return false;
}); });
}); });
var register_handlers = function() {
$('.delete-btn').click(function() {
$(this).parent().remove();
return false;
});
}
</script> </script>
{% endblock %} {% endblock %}
@ -87,12 +102,11 @@
</select> </select>
<br> <br>
<label>Notes</label> <label>Notes</label>
<input type="text" class="span6" name="notes" <input type="text" class="span6" name="notes" value="{{match.notes}}">
value="{{match.notes}}">
<br> <br>
<button class="btn">Add Team</button> <button class="btn">Add Team</button>
<button class="btn">Add Member</button> <button class="btn">Add Member</button>
<button class="btn btn-danger">Delete Match</button> <button class="btn btn-danger delete-btn">Delete Match</button>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -76,6 +76,7 @@ def edit_event(request, event):
return render(request, "edit_event.html", return render(request, "edit_event.html",
{'event': event, {'event': event,
'stars': Star.objects.all(),
'OUTCOMES': OUTCOMES, 'OUTCOMES': OUTCOMES,
'TITLES': TITLES} 'TITLES': TITLES}
) )