Permalink
Browse files

add csv export of member applications

  • Loading branch information...
1 parent 82065ee commit bd149825fe83d2580a8daaabf6212f0428e3b567 @nicpottier nicpottier committed May 9, 2012
Showing with 50 additions and 3 deletions.
  1. +17 −1 klab/members/views.py
  2. +3 −2 klab/settings_common.py
  3. +30 −0 templates/members/application_list.html
View
@@ -4,7 +4,7 @@
class ApplicationCRUDL(SmartCRUDL):
model = Application
- actions = ('create', 'read', 'update', 'list', 'thanks')
+ actions = ('create', 'read', 'update', 'list', 'thanks', 'csv')
permissions = True
class Read(SmartReadView):
@@ -23,6 +23,22 @@ def get_applying_for(self, obj):
def get_frequency(self, obj):
return obj.get_frequency_display()
+ class Csv(SmartCsvView):
+ fields = ('created_on', 'name', 'email', 'professional_status', 'applying_for', 'frequency', 'city', 'country', 'goals', 'education', 'experience')
+
+ def derive_queryset(self, **kwargs):
+ queryset = super(ApplicationCRUDL.Csv, self).derive_queryset(**kwargs)
+ return queryset.filter(is_active=True)
+
+ def get_professional_status(self, obj):
+ return obj.get_professional_status_display()
+
+ def get_applying_for(self, obj):
+ return obj.get_applying_for_display()
+
+ def get_frequency(self, obj):
+ return obj.get_frequency_display()
+
class List(SmartListView):
fields = ('name', 'email', 'applying_for', 'city', 'country', 'created_on')
search_fields = ('first_name__icontains', 'last_name__icontains')
View
@@ -107,6 +107,7 @@
'update', # can update an object
'delete', # can delete an object,
'list'), # can view a list of the objects
+ 'members.application': ('csv',),
}
# assigns the permissions that each group should have, here creating an Administrator group with
@@ -120,8 +121,8 @@
"Editors": ('events.event.*',
'blog.post.*',
'django_quickblocks.quickblock.*',
- 'members.application_list',
- 'members.application_read'),
+ 'members.application_list', 'members.application_read', 'members.application_csv',
+ ),
}
#-----------------------------------------------------------------------------------
@@ -0,0 +1,30 @@
+{% extends "smartmin/list.html" %}
+
+{% block table-controls %}
+<div class="row">
+ <div class="span6">
+ {% if view.search_fields %}
+ <form class="form-search">
+ <input type="text" class="input-medium search-query" name="search" value="{{ search }}">
+ <button type="submit" class="btn">Search</button>
+ </form>
+ {% else %}
+ &nbsp;
+ {% endif %}
+ </div>
+
+ <div class="span6 buttons">
+ {% block table-buttons %}
+ <div class="pull-right">
+ {% if perms.members.application_csv %}
+ <a class="btn" href="{% url members.application_csv %}">Export</a>
+ {% endif %}
+
+ {% if view.add_button %}
+ <a class="btn btn-primary" href="./create/">Add</a>
+ {% endif %}
+ </div>
+ {% endblock table-buttons %}
+ </div>
+</div>
+{% endblock %}

0 comments on commit bd14982

Please sign in to comment.