Commit 54df9f8b authored by Olga Brani's avatar Olga Brani
Browse files

Astakos tables fixes

parent 46087a08
...@@ -1160,6 +1160,8 @@ class ProjectApplication(models.Model): ...@@ -1160,6 +1160,8 @@ class ProjectApplication(models.Model):
try: try:
membership = self.project.projectmembership_set.get(person=user) membership = self.project.projectmembership_set.get(person=user)
status = membership.state status = membership.state
except Project.DoesNotExist:
status = -1
except ProjectMembership.DoesNotExist: except ProjectMembership.DoesNotExist:
status = -1 status = -1
......
...@@ -34,20 +34,23 @@ class UserProjectApplicationsTable(tables.Table): ...@@ -34,20 +34,23 @@ class UserProjectApplicationsTable(tables.Table):
name = tables.LinkColumn('astakos.im.views.project_detail', args=(A('pk'),)) name = tables.LinkColumn('astakos.im.views.project_detail', args=(A('pk'),))
issue_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT) issue_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT)
start_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT) start_date = tables.DateColumn(format=DEFAULT_DATE_FORMAT)
state = tables.Column(verbose_name="Status") membership_status = tables.Column(verbose_name=_("Status"), empty_values=(),
orderable=False)
members_count = tables.Column(verbose_name=_("Enrolled"), default=0, members_count = tables.Column(verbose_name=_("Enrolled"), default=0,
sortable=False) sortable=False)
membership_status = tables.Column(verbose_name=_("My status"), empty_values=(),
orderable=False)
def render_membership_status(self, *args, **kwargs): def render_membership_status(self, record, *args, **kwargs):
return MEMBER_STATUS_DISPLAY.get(kwargs.get('record').member_status(self.user)) status = record.member_status(self.user)
if status == 100:
return record.state
else:
return MEMBER_STATUS_DISPLAY.get(status, 'Unknown')
class Meta: class Meta:
model = ProjectApplication model = ProjectApplication
fields = ('name', 'membership_status', 'issue_date', 'start_date', fields = ('name', 'membership_status', 'issue_date', 'start_date', 'members_count')
'state', 'members_count')
attrs = {'id': 'projects-list', 'class': 'my-projects alt-style'} attrs = {'id': 'projects-list', 'class': 'my-projects alt-style'}
caption = _('My projects') caption = _('My projects')
template = "im/table_render.html" template = "im/table_render.html"
......
...@@ -1111,7 +1111,7 @@ def project_list(request): ...@@ -1111,7 +1111,7 @@ def project_list(request):
projects = ProjectApplication.objects.user_projects(request.user).select_related() projects = ProjectApplication.objects.user_projects(request.user).select_related()
table = tables.UserProjectApplicationsTable(projects, user=request.user, table = tables.UserProjectApplicationsTable(projects, user=request.user,
prefix="my_projects_") prefix="my_projects_")
RequestConfig(request).configure(table) RequestConfig(request, paginate={"per_page": PAGINATE_BY}).configure(table)
return object_list( return object_list(
request, request,
...@@ -1193,7 +1193,7 @@ def project_detail(request, application_id): ...@@ -1193,7 +1193,7 @@ def project_detail(request, application_id):
members = application.project.projectmembership_set.select_related() members = application.project.projectmembership_set.select_related()
members_table = tables.ProjectApplicationMembersTable(members, members_table = tables.ProjectApplicationMembersTable(members,
prefix="members_") prefix="members_")
RequestConfig(request).configure(members_table) RequestConfig(request, paginate={"per_page": PAGINATE_BY}).configure(members_table)
try: try:
return object_detail( return object_detail(
...@@ -1238,7 +1238,7 @@ def project_search(request): ...@@ -1238,7 +1238,7 @@ def project_search(request):
table = tables.UserProjectApplicationsTable(projects, user=request.user, table = tables.UserProjectApplicationsTable(projects, user=request.user,
prefix="my_projects_") prefix="my_projects_")
RequestConfig(request).configure(table) RequestConfig(request, paginate={"per_page": PAGINATE_BY}).configure(table)
return object_list( return object_list(
request, request,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment