Revision db9a498c snf-astakos-app/astakos/im/tables.py

b/snf-astakos-app/astakos/im/tables.py
176 176
        return contexts
177 177

  
178 178

  
179
def action_extra_context(project, table, self):
179
def action_extra_context(application, table, self):
180 180
    user = table.user
181 181
    url, action, confirm, prompt = '', '', True, ''
182 182
    append_url = ''
183 183

  
184
    if user.owns_project(project):
185
        url = 'astakos.im.views.project_update'
186
        action = _('Update')
187
        confirm = False
188
        prompt = ''
189
    elif user.is_project_accepted_member(project):
190
        url = 'astakos.im.views.project_leave'
191
        action = _('- Leave')
192
        confirm = True
193
        prompt = _('Are you sure you want to leave from the project ?')
194
    elif not user.is_project_member(project):
195
        url = 'astakos.im.views.project_join'
196
        action = _('+ Join')
197
        confirm = True
198
        prompt = _('Are you sure you want to join this project ?')
199
    else:
200
        action = ''
201
        confirm = False
202
        url = None
203

  
204
    url = reverse(url, args=(project.pk, )) + append_url if url else ''
184
    can_join = True
185

  
186
    try:
187
        project = Project.objects.get(application=application)
188
        do_join_project_checks(project)
189
    except (PermissionDenied, Project.DoesNotExist), e:
190
        can_join = False
191

  
192
    if can_join:
193
        if user.is_project_accepted_member(application):
194
            url = 'astakos.im.views.project_leave'
195
            action = _('Leave')
196
            confirm = True
197
            prompt = _('Are you sure you want to leave from the project ?')
198
        elif not user.is_project_member(application):
199
            url = 'astakos.im.views.project_join'
200
            action = _('Join')
201
            confirm = True
202
            prompt = _('Are you sure you want to join this project ?')
203
        else:
204
            action = ''
205
            confirm = False
206
            url = None
207

  
208
    url = reverse(url, args=(application.pk, )) + append_url if url else ''
205 209
    return {'action': action,
206 210
            'confirm': confirm,
207 211
            'url': url,
......
272 276
    if membership.state == ProjectMembership.ACCEPTED:
273 277
        urls = ['astakos.im.views.project_remove_member']
274 278
        actions = [_('Remove')]
279
        if table.user == membership.person:
280
            actions = [_('Leave')]
275 281
        prompts = [_('Are you sure you want to remove this member ?')]
276 282
        confirms = [True, True]
277 283

  
......
302 308
        return record.person.realname
303 309

  
304 310
    def render_status(self, value, *args, **kwargs):
305
        return MEMBER_STATUS_DISPLAY.get(value, 'Unknown')
311
        return USER_STATUS_DISPLAY.get(value, 'Unknown')
306 312

  
307 313
    class Meta:
308 314
        template = "im/table_render.html"

Also available in: Unified diff