diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-04-10 18:33:10 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-04-10 18:33:10 (GMT) |
commit | 859b0cb47bafe196a2682dbddb312752ad00eb14 (patch) | |
tree | 54b7fa363ccaa04439c28c82d0cc3972a959af47 /webapp | |
parent | a62b2305ddc31810944627a6f0fd45059dd612fa (diff) |
BugFix: poll list table
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/polls/templates/poll-list.html | 12 | ||||
-rw-r--r-- | webapp/polls/views.py | 30 |
2 files changed, 28 insertions, 14 deletions
diff --git a/webapp/polls/templates/poll-list.html b/webapp/polls/templates/poll-list.html index 0a3efd6..2c9e6ba 100644 --- a/webapp/polls/templates/poll-list.html +++ b/webapp/polls/templates/poll-list.html @@ -3,7 +3,7 @@ {% block main_container %} <script type="text/javascript"> - var sortingOrder = 'name'; + var sortingOrder = 'status'; var searchableFields = ['name', 'status']; </script> @@ -12,7 +12,7 @@ <input type="text" ng-model="query" ng-change="search()" class="input-large search-query" placeholder="Search"> <span class="add-on"><i class="icon-search"></i></span> </div> - <table class="table table-striped table-condensed table-hover table-bordered"> + <table class="table table-condensed table-hover table-bordered"> <thead> <tr> <th class="name span5">Nombre <a ng-click="sort_by('name')"><i class="icon-sort"></i></a></th> @@ -21,21 +21,21 @@ </tr> </thead> <tbody> - <tr ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse" style="background-color: {% if item.is_open %}#f2dede;{% else %}#e8f4db{% endif %}"> + <tr ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse" style="background-color: {% ng item.background_color %};"> <td>{% ng item.name %}</td> <td>{% ng item.status %}</td> <td> - <a class="btn {% if not item.is_open or not user.is_superuser %}disabled{% endif %}" href="{% ng item.action_edit %}"> + <a class="btn {% ng item.action_edit.disabled %}" href="{% ng item.action_edit.url %}"> <i class="icon-edit"></i> Modificar datos de encuesta </a> </td> <td> - <a class="btn {% if not item.is_open %}disabled{% endif %}" href="{% ng item.action_structure_builder %}"> + <a class="btn {% ng item.action_structure_builder.disabled %}" href="{% ng item.action_structure_builder.url %}"> <i class="icon-wrench"></i> Modificar estructura </a> </td> <td> - <a class="btn {% if item.is_open %}disabled{% endif %}" href="{% ng item.action_download %}"> + <a class="btn {% ng item.action_download.disabled %}" href="{% ng item.action_download.url %}"> <i class="icon-download-alt"></i> Descargar encuesta </a> </td> diff --git a/webapp/polls/views.py b/webapp/polls/views.py index c7e21f6..e4b2cdd 100644 --- a/webapp/polls/views.py +++ b/webapp/polls/views.py @@ -133,19 +133,33 @@ class PollListView(ListView): context_object_name = "polls" def get_queryset(self, *args, **kwargs): + user = self.request.user return [ { 'name': poll.name, 'status': poll.status, 'is_open': poll.is_open(), - 'action_edit': reverse( - 'polls:edit', kwargs={'id': str(poll.id)}), - 'action_structure_builder': reverse( - 'polls:structure.builder', - kwargs={'poll_id': str(poll.id)} - ), - 'action_download': reverse( - 'polls:download', kwargs={'poll_id': str(poll.id)}), + 'action_edit': { + 'disabled': not poll.is_open() or not user.is_superuser, + 'url': reverse( + 'polls:edit', kwargs={'id': str(poll.id)} + ), + }, + 'action_structure_builder': { + 'disabled': not poll.is_open(), + 'url': reverse( + 'polls:structure.builder', + kwargs={'poll_id': str(poll.id)} + ) + }, + 'action_download': { + 'disabled': poll.is_open(), + 'url': reverse( + 'polls:download', + kwargs={'poll_id': str(poll.id)} + ), + }, + 'background_color': "#f2dede" if poll.is_open() else "#e8f4db" } for poll in Poll.all( sort=[('status', ASCENDING), ('name', ASCENDING)]) ] |