コード例 #1
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['building'] = self.get_object()
        context['active_units'] = True
        context['can_create_unit'] = BuildingPermissions.can_create_unit(
            user=self.request.user,
            building=self.get_object(),
        )

        context[
            'can_view_unit_detail'] = BuildingPermissions.can_view_unit_detail(
                user=self.request.user,
                building=self.get_object(),
            )

        context[
            'can_view_update_menu'] = BuildingPermissions.can_edit_building(
                user=self.request.user,
                building=self.get_object(),
            )

        context['can_edit_unit'] = BuildingPermissions.can_edit_unit(
            user=self.request.user,
            building=self.get_object(),
        )

        return context
コード例 #2
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['can_edit_building'] = BuildingPermissions.can_edit_building(
            user=self.request.user,
            building=self.get_object(),
        )

        context['active_general'] = True

        return context
コード例 #3
0
 def test_func(self):
     return BuildingPermissions.can_edit_building(
         user=self.request.user,
         building=self.get_object(),
     )