Revision 2743e261
b/snf-astakos-app/astakos/im/tables.py | ||
---|---|---|
31 | 31 |
|
32 | 32 |
super(UserProjectApplicationsTable, self).__init__(*args, **kwargs) |
33 | 33 |
|
34 |
|
|
35 | 34 |
name = tables.LinkColumn('astakos.im.views.project_detail', args=(A('pk'),)) |
36 | 35 |
issue_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT) |
37 | 36 |
start_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT) |
38 | 37 |
state = tables.Column(verbose_name="Status") |
39 |
members_count = tables.Column(verbose_name="Enrolled", default=0,
|
|
38 |
members_count = tables.Column(verbose_name=_("Enrolled"), default=0,
|
|
40 | 39 |
sortable=False) |
41 |
membership_status = tables.Column(verbose_name="My status", empty_values=(),
|
|
40 |
membership_status = tables.Column(verbose_name=_("My status"), empty_values=(),
|
|
42 | 41 |
orderable=False) |
43 | 42 |
|
43 |
|
|
44 | 44 |
def render_membership_status(self, *args, **kwargs): |
45 | 45 |
return MEMBER_STATUS_DISPLAY.get(kwargs.get('record').member_status(self.user)) |
46 | 46 |
|
... | ... | |
48 | 48 |
model = ProjectApplication |
49 | 49 |
fields = ('name', 'membership_status', 'issue_date', 'start_date', |
50 | 50 |
'state', 'members_count') |
51 |
attrs = {'id': 'projects-list', 'class': 'my-projects alt-style'} |
|
52 |
caption = _('My projects') |
|
53 |
template = "im/table_render.html" |
|
54 |
|
|
55 |
|
|
56 |
class ProjectApplicationMembersTable(tables.Table): |
|
57 |
name = tables.Column(accessor="person.last_name", verbose_name=_('Name')) |
|
58 |
status = tables.Column(accessor="state", verbose_name=_('Status')) |
|
59 |
|
|
60 |
|
|
61 |
def render_name(self, value, record, *args, **kwargs): |
|
62 |
return record.person.last_name |
|
63 |
|
|
64 |
def render_status(self, value, *args, **kwargs): |
|
65 |
return MEMBER_STATUS_DISPLAY.get(value, 'Unknown') |
|
66 |
|
|
67 |
class Meta: |
|
68 |
template = "im/table_render.html" |
|
69 |
model = ProjectMembership |
|
70 |
fields = ('name', 'status') |
|
71 |
attrs = {'id': 'members-table', 'class': 'members-table alt-style'} |
|
51 | 72 |
|
b/snf-astakos-app/astakos/im/templates/im/projects/project_detail.html | ||
---|---|---|
1 | 1 |
{% extends "im/account_base.html" %} |
2 | 2 |
|
3 |
{% load filters %}
|
|
3 |
{% load astakos_tags filters django_tables2 %}
|
|
4 | 4 |
|
5 | 5 |
{% block page.body %} |
6 | 6 |
{% with object.project.approved_members as approved_members %} |
... | ... | |
127 | 127 |
</div> |
128 | 128 |
{% if object.project.is_alive %} |
129 | 129 |
<div class="full-dotted"> |
130 |
{% with page|concat:sorting as args %} |
|
131 |
{% with object.project.projectmembership_set.select_related.all|paginate:args as membership %} |
|
132 |
{% if membership %} |
|
133 |
|
|
134 |
<table class="alt-style" id="members-table"> |
|
135 |
<caption>MEMBERS:</caption> |
|
136 |
<thead> |
|
137 |
<tr> |
|
138 |
{%if user.is_superuser or user == object.owner %}<th>User Email</th>{% endif %} |
|
139 |
<th>Name</th> |
|
140 |
<th>Status</th> |
|
141 |
</tr> |
|
142 |
</thead> |
|
143 |
<tbody> |
|
144 |
{% for m in membership.object_list %} |
|
145 |
<tr> |
|
146 |
{%if user.is_superuser or user == object.owner %}<td>{{m.person.email}}</td>{% endif %} |
|
147 |
<td>{{m.person.realname}}</td> |
|
148 |
{% if m.person == object.owner %} |
|
149 |
<td>Owner</td> |
|
150 |
{% else %} |
|
151 |
{% if m.acceptance_date %} |
|
152 |
<td>Approved {% if m.leave_request_date%}(User has requested to leave the project on:{{m.leave_request_date}}){% endif %} |
|
153 |
{% if user == object.owner and user != m.person %} |
|
154 |
<a href="{% url project_remove_member object.id m.person.id %}?{% if page %}page={{ page }}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">Remove</a> |
|
155 |
{% endif %} |
|
156 |
</td> |
|
157 |
{% else %} |
|
158 |
<td>Pending |
|
159 |
{% if user == object.owner %} |
|
160 |
<a href="{% url project_accept_member object.id m.person.id %}?{% if page %}page={{ page }}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">Accept</a> |
|
161 |
<a href="{% url project_reject_member object.id m.person.id %}?{% if page %}page={{ page }}{% endif %}{% if sorting %}&sorting={{sorting}}{% endif %}">Reject</a> |
|
162 |
{% endif %} |
|
163 |
</td> |
|
164 |
{% endif %} |
|
165 |
{% endif %} |
|
166 |
</tr> |
|
167 |
{% endfor %} |
|
168 |
</tbody> |
|
169 |
</table> |
|
170 |
<div class="pagination"> |
|
171 |
<p class="next-prev"> |
|
172 |
{% if membership.has_previous %} |
|
173 |
<a href="?page={{ membership.previous_page_number }}{% if sorting %}&sorting={{sorting}}{% endif %}">< previous</a> |
|
174 |
{% else %} |
|
175 |
<a href="javascript:void()" class="disabled">< previous</a> |
|
176 |
{% endif %} |
|
177 |
{% if membership.has_next %} |
|
178 |
<a href="?page={{ membership.next_page_number }}{% if sorting %}&sorting={{sorting}}{% endif %}">next ></a> |
|
179 |
{% else %} |
|
180 |
<a href="javascript:void()" class="disabled">next ></a> |
|
181 |
{% endif %} |
|
182 |
</p> |
|
183 |
<p class="nums"> |
|
184 |
<span class="current"> |
|
185 |
Page {{ membership.number }} of {{ membership.paginator.num_pages }} |
|
186 |
</span> |
|
187 |
</p> |
|
188 |
</div> |
|
189 |
{% else %} |
|
190 |
<p>No members yet!</p> |
|
191 |
{% endif %} |
|
192 |
{% endwith %} |
|
193 |
{% endwith %} |
|
130 |
<h3>MEMBERS</h3> |
|
131 |
{% if members_table %} |
|
132 |
{% render_table members_table %} |
|
133 |
{% endif %} |
|
194 | 134 |
</div> |
195 | 135 |
|
196 | 136 |
|
b/snf-astakos-app/astakos/im/templates/im/projects/project_list.html | ||
---|---|---|
1 | 1 |
{% extends "im/account_base.html" %} |
2 |
|
|
3 |
{% load astakos_tags %} |
|
4 |
{% load filters %} |
|
5 |
{% load django_tables2 %} |
|
2 |
{% load astakos_tags filters django_tables2 %} |
|
6 | 3 |
|
7 | 4 |
{% block page.body %} |
8 | 5 |
<div class="maincol {% block innerpage.class %}{% endblock %}"> |
b/snf-astakos-app/astakos/im/templates/im/table_render.html | ||
---|---|---|
1 |
{% spaceless %} |
|
2 |
{% load django_tables2 %} |
|
3 |
{% load i18n %} |
|
4 |
{% if table.page %} |
|
5 |
<div class="table-container"> |
|
6 |
{% endif %} |
|
7 |
{% block table %} |
|
8 |
<table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}> |
|
9 |
{% if table.attrs.caption %} |
|
10 |
<caption>{{ table.attrs.caption }}</caption> |
|
11 |
{% endif %} |
|
12 |
{% nospaceless %} |
|
13 |
{% block table.thead %} |
|
14 |
<thead> |
|
15 |
<tr> |
|
16 |
{% for column in table.columns %} |
|
17 |
{% if column.orderable %} |
|
18 |
<th {{ column.attrs.th.as_html }}><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}#{{ table.attrs.id }}">{{ column.header }}</a></th> |
|
19 |
{% else %} |
|
20 |
<th {{ column.attrs.th.as_html }}>{{ column.header }}</th> |
|
21 |
{% endif %} |
|
22 |
{% endfor %} |
|
23 |
</tr> |
|
24 |
</thead> |
|
25 |
{% endblock table.thead %} |
|
26 |
{% block table.tbody %} |
|
27 |
<tbody> |
|
28 |
{% for row in table.page.object_list|default:table.rows %} {# support pagination #} |
|
29 |
{% block table.tbody.row %} |
|
30 |
<tr class="{% cycle "odd" "even" %}"> |
|
31 |
{% for column, cell in row.items %} |
|
32 |
<td {{ column.attrs.td.as_html }}>{{ cell }}</td> |
|
33 |
{% endfor %} |
|
34 |
</tr> |
|
35 |
{% endblock table.tbody.row %} |
|
36 |
{% empty %} |
|
37 |
{% if table.empty_text %} |
|
38 |
{% block table.tbody.empty_text %} |
|
39 |
<tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr> |
|
40 |
{% endblock table.tbody.empty_text %} |
|
41 |
{% endif %} |
|
42 |
{% endfor %} |
|
43 |
</tbody> |
|
44 |
{% endblock table.tbody %} |
|
45 |
{% block table.tfoot %} |
|
46 |
<tfoot></tfoot> |
|
47 |
{% endblock table.tfoot %} |
|
48 |
{% endnospaceless %} |
|
49 |
</table> |
|
50 |
{% endblock table %} |
|
51 |
|
|
52 |
{% if table.page %} |
|
53 |
{% with table.page.paginator.count as total %} |
|
54 |
{% with table.page.object_list|length as count %} |
|
55 |
{% block pagination %} |
|
56 |
<ul class="pagination"> |
|
57 |
{% if table.page.has_previous %} |
|
58 |
{% nospaceless %}{% block pagination.previous %}<li class="previous"><a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}#{{ table.attrs.id }}">{% trans "Previous" %}</a></li>{% endblock pagination.previous %}{% endnospaceless %} |
|
59 |
{% endif %} |
|
60 |
|
|
61 |
{% if table.page.has_previous or table.page.has_next %} |
|
62 |
{% nospaceless %}{% block pagination.current %}<li class="current">{% blocktrans with table.page.number as current and table.paginator.num_pages as total %}Page {{ current }} of {{ total }}{% endblocktrans %}</li>{% endblock pagination.current %}{% endnospaceless %} |
|
63 |
{% endif %} |
|
64 |
|
|
65 |
{% if table.page.has_next %} |
|
66 |
{% nospaceless %}{% block pagination.next %}<li class="next"><a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}#{{ table.attrs.id }}">{% trans "Next" %}</a></li>{% endblock pagination.next %}{% endnospaceless %} |
|
67 |
{% endif %} |
|
68 |
|
|
69 |
{% nospaceless %}{% block pagination.cardinality %}<li class="cardinality">{% if total != count %}{% blocktrans %}{{ count }} of {{ total }}{% endblocktrans %}{% else %}{{ total }}{% endif %} {% if total == 1 %}{{ table.data.verbose_name }}{% else %}{{ table.data.verbose_name_plural }}{% endif %}</li>{% endblock pagination.cardinality %}{% endnospaceless %} |
|
70 |
</ul> |
|
71 |
{% endblock pagination %} |
|
72 |
{% endwith %} |
|
73 |
{% endwith %} |
|
74 |
</div> |
|
75 |
{% endif %} |
|
76 |
{% endspaceless %} |
b/snf-astakos-app/astakos/im/views.py | ||
---|---|---|
1096 | 1096 |
) |
1097 | 1097 |
else: |
1098 | 1098 |
resource_catalog = result.data |
1099 |
extra_context = {'resource_catalog':resource_catalog, 'show_form':True, 'details_fields':details_fields, 'membership_fields':membership_fields} |
|
1099 |
extra_context = {'resource_catalog':resource_catalog, 'show_form':True, |
|
1100 |
'details_fields':details_fields, |
|
1101 |
'membership_fields':membership_fields} |
|
1100 | 1102 |
return _create_object(request, template_name='im/projects/projectapplication_form.html', |
1101 | 1103 |
extra_context=extra_context, post_save_redirect=reverse('project_list'), |
1102 | 1104 |
form_class=ProjectApplicationForm) |
... | ... | |
1107 | 1109 |
@login_required |
1108 | 1110 |
def project_list(request): |
1109 | 1111 |
projects = ProjectApplication.objects.user_projects(request.user).select_related() |
1110 |
table = tables.UserProjectApplicationsTable(projects, user=request.user, prefix="my_projects") |
|
1112 |
table = tables.UserProjectApplicationsTable(projects, user=request.user, |
|
1113 |
prefix="my_projects_") |
|
1111 | 1114 |
RequestConfig(request).configure(table) |
1112 | 1115 |
|
1113 | 1116 |
return object_list( |
... | ... | |
1184 | 1187 |
transaction.commit() |
1185 | 1188 |
addmembers_form = AddProjectMembersForm() |
1186 | 1189 |
|
1187 |
# validate sorting |
|
1188 |
sorting = 'person__email' |
|
1189 |
form = ProjectMembersSortForm(request.GET or request.POST) |
|
1190 |
if form.is_valid(): |
|
1191 |
sorting = form.cleaned_data.get('sorting') |
|
1192 |
|
|
1193 | 1190 |
rollback = False |
1191 |
|
|
1192 |
application = get_object_or_404(ProjectApplication, pk=application_id) |
|
1193 |
members = application.project.projectmembership_set.select_related() |
|
1194 |
members_table = tables.ProjectApplicationMembersTable(members, |
|
1195 |
prefix="members_") |
|
1196 |
RequestConfig(request).configure(members_table) |
|
1197 |
|
|
1194 | 1198 |
try: |
1195 | 1199 |
return object_detail( |
1196 | 1200 |
request, |
... | ... | |
1199 | 1203 |
template_name='im/projects/project_detail.html', |
1200 | 1204 |
extra_context={ |
1201 | 1205 |
'resource_catalog':resource_catalog, |
1202 |
'sorting':sorting, |
|
1203 |
'addmembers_form':addmembers_form |
|
1204 |
} |
|
1205 |
) |
|
1206 |
except: |
|
1206 |
'addmembers_form':addmembers_form, |
|
1207 |
'members_table': members_table |
|
1208 |
}) |
|
1209 |
except Exception, e: |
|
1207 | 1210 |
rollback = True |
1208 | 1211 |
finally: |
1209 | 1212 |
if rollback == True: |
... | ... | |
1233 | 1236 |
projects = ProjectApplication.objects.search_by_name(q) |
1234 | 1237 |
projects = projects.filter(~Q(project__last_approval_date__isnull=True)) |
1235 | 1238 |
|
1236 |
table = tables.UserProjectApplicationsTable(projects, user=request.user, prefix="my_projects") |
|
1239 |
table = tables.UserProjectApplicationsTable(projects, user=request.user, |
|
1240 |
prefix="my_projects_") |
|
1237 | 1241 |
RequestConfig(request).configure(table) |
1238 | 1242 |
|
1239 | 1243 |
return object_list( |
Also available in: Unified diff