Changeset 56e8cb8
- Timestamp:
- Oct 12, 2011, 10:54:21 PM (14 years ago)
- Branches:
- master, space-access, stable, stage, test-hooks
- Children:
- 8dfd3db
- Parents:
- ce7fd92
- git-author:
- Alex Dehnert <adehnert@…> (10/12/11 22:54:21)
- git-committer:
- Alex Dehnert <adehnert@…> (10/12/11 22:54:21)
- Location:
- asadb
- Files:
-
- 2 edited
-
forms/views.py (modified) (3 diffs)
-
template/membership/confirm.html (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
asadb/forms/views.py
r4260e2c r56e8cb8 1 1 import forms.models 2 2 import groups.models 3 import groups.views 3 4 import settings 4 5 … … 367 368 update_obj.valid = forms.models.VALID_AUTOREJECTED 368 369 370 qs = groups.models.Group.active_groups 371 filterset = groups.views.GroupFilter(request.GET, qs) 372 filtered_groups = filterset.qs.all() 373 show_filtered_groups = ('search' in request.GET) 374 369 375 message = "" 370 if request.method == 'POST': # If the form has been submitted... 376 message_type = "info" 377 378 if request.method == 'POST' and 'add-remove' in request.POST: 379 group = groups.models.Group.objects.get(id=request.POST['group']) 380 if request.POST['action'] == 'remove': 381 if group in update_obj.groups.all(): 382 update_obj.groups.remove(group) 383 message = "You have been successfully removed from %s." % (group, ) 384 else: 385 message = "Sorry, but you're not in %s." % (group, ) 386 message_type = "warn" 387 elif request.POST['action'] == 'add': 388 if group in update_obj.groups.all(): 389 message = "Sorry, but you're already in %s." % (group, ) 390 message_type = "warn" 391 else: 392 update_obj.groups.add(group) 393 message = "You have been successfully added to %s." % (group, ) 394 else: 395 message = "Uh, somehow you tried to do something besides adding and removing..." 396 message_type = "alert" 397 398 if request.method == 'POST' and 'list' in request.POST: # If the form has been submitted... 371 399 form = Form_PersonMembershipUpdate(request.POST, request.FILES, instance=update_obj) # A form bound to the POST data 372 400 … … 380 408 context = { 381 409 'form':form, 382 'groups':selected_groups, 410 'filter':filterset, 411 'show_filtered_groups':show_filtered_groups, 412 'filtered_groups':filtered_groups, 413 'member_groups':selected_groups, 383 414 'message': message, 415 'message_type': message_type, 384 416 'pagename':'groups', 385 417 } -
asadb/template/membership/confirm.html
rc297267 r56e8cb8 7 7 8 8 {% if message %} 9 <div class='messagebox infobox'>9 <div class='messagebox {{message_type}}box'> 10 10 <p>{{message}}</p> 11 11 </div> … … 17 17 </p> 18 18 19 <p> 20 Please select below the groups that you consider yourself a member of. If you 21 come back to this form again, you'll be able to see all the groups you 22 previously submitted, and add new groups. However, you should be careful not to 23 deselect any groups. 24 </p> 19 <p>We ask you to help with that process by indicating what groups you consider yourself a member of.</p> 20 21 <h3>Groups you currently say you're a member of:</h3> 22 {% if member_groups %} 23 <ul> 24 {% for group in member_groups %} 25 <li>{{group}}</li> 26 {% endfor %} 27 </ul> 28 {% else %} 29 <p>You are not currently indicating membership in any groups.</p> 30 {% endif %} 31 32 <h3>Option 1: Add or remove groups one at a time</h3> 33 34 <form action="" method="get"> 35 <table class='pretty-table'> 36 {{ filter.form.as_table }} 37 </table> 38 <input type="submit" name='search' value="Search" /> 39 <input type="submit" name='stop-search' value="Stop searching" /> 40 </form> 41 42 {% if show_filtered_groups %} 43 <table class='pretty-table'> 44 <thead> 45 <tr> 46 <th>Name</th> 47 <th>Website</th> 48 <th>ASA DB</th> 49 <th>Description</th> 50 <th>Add/Remove</th> 51 </tr> 52 </thead> 53 <tbody> 54 {% for group in filtered_groups %} 55 <tr> 56 <th>{{group.name}}</th> 57 <td>{% if group.website_url %}<a href='{{group.website_url}}'>Website</a>{%endif%}</td> 58 <td><a href='{% url groups:group-detail group.pk %}'>DB Entry</a></td> 59 <td>{{group.description}}</td> 60 <td> 61 <form action="" method="post"> 62 {% csrf_token %} 63 <input type="hidden" name="group" value="{{group.pk}}"> 64 {% if group in member_groups %} 65 <input type="hidden" name="action" value="remove"> 66 <input type="submit" name="add-remove" value="Remove"> 67 {% else %} 68 <input type="hidden" name="action" value="add"> 69 <input type="submit" name="add-remove" value="Add"> 70 {% endif %} 71 </form> 72 </td> 73 </tr> 74 {% endfor %} 75 </tbody> 76 </table> 77 {% else %} 78 <p>Hit "search" to see matching groups.</p> 79 {% endif %} 80 81 82 <h3>Option 2: Select all your groups at once</h3> 83 84 <p>Below is a list of all recognized groups. You can go through picking out the groups you are a member of. However, you should be careful not to deselect any groups (unless you aren't a member of them, of course).</p> 25 85 26 86 <form enctype="multipart/form-data" method="post" action=""> … … 28 88 <table class='pretty-table'> 29 89 {{ form.as_table }} 30 <tr><th colspan='2'><input type='submit' value='Confirm membership' /></th></tr>90 <tr><th colspan='2'><input type='submit' name='list' value='Update list of groups' /></th></tr> 31 91 </table> 32 92 </form> 33 93 34 {% if groups %}35 <h3>Groups saved</h3>36 <ul>37 {% for group in groups %}38 <li>{{group}}</li>39 {% endfor %}40 </ul>41 {% endif %}42 43 94 {% endblock %}
Note: See TracChangeset
for help on using the changeset viewer.