Example #1
0
 def test_get_url_with_pagination_prev(self):
     req = self.request
     url_string = 'horizon:project:instances:index'
     req.GET.update({'prev': 'id'})
     url = views.get_url_with_pagination(
         req, None, 'prev', url_string, None)
     self.assertEqual(six.text_type('/project/instances/?prev=id'), url)
Example #2
0
 def test_get_url_with_pagination_prev(self):
     req = self.request
     url_string = 'horizon:project:instances:index'
     req.GET.update({'prev': 'id'})
     url = views.get_url_with_pagination(req, None, 'prev', url_string,
                                         None)
     self.assertEqual('/project/instances/?prev=id', url)
Example #3
0
def get_server_detail_link(obj, request):
    roles=[]
    for role in request.user.roles:
        roles.append(role.get('name'))

    if roles.__contains__('project_manager') or roles.__contains__('user'):
        return get_url_with_pagination(request,
                                    InstancesTable._meta.pagination_param,
                                    InstancesTable._meta.prev_pagination_param,
                                    'horizon:project:instances:detail',
                                    obj.id)
    else : 
        return get_url_with_pagination(
            request, AdminInstancesTable._meta.pagination_param,
            AdminInstancesTable._meta.prev_pagination_param,
            "horizon:admin:instances:detail", obj.id)
Example #4
0
 def test_get_url_with_pagination_next(self):
     req = self.request
     url_string = 'horizon:project:instances:index'
     req.GET.update({'next': 'id'})
     url = views.get_url_with_pagination(
         req, 'next', None, url_string, None)
     self.assertEqual(six.text_type('/project/instances/?next=id'), url)
Example #5
0
def get_monitoring_detail_link(obj, request):
    """
    Redirection to monitoring details
    """
    return get_url_with_pagination(request,
                                   InstancesTable._meta.pagination_param,
                                   InstancesTable._meta.prev_pagination_param,
                                   "horizon:project:monitoring:detail", obj.id)
Example #6
0
def get_server_detail_link(obj, request):
    """
    Redirection to instance details
    """
    return get_url_with_pagination(request,
                                   InstancesTable._meta.pagination_param,
                                   InstancesTable._meta.prev_pagination_param,
                                   "horizon:project:instances:detail", obj.id)
Example #7
0
    def get_context_data(self, **kwargs):
        context = super(DetailView, self).get_context_data(**kwargs)
        instance = self.get_data()
        if instance.image:
            instance.image_url = reverse(self.image_url,
                                         args=[instance.image['id']])
        instance.volume_url = self.volume_url
        context["instance"] = instance
        context["url"] = get_url_with_pagination(
            self.request, project_tables.InstancesTable._meta.pagination_param,
            project_tables.InstancesTable._meta.prev_pagination_param,
            self.redirect_url)

        context["actions"] = self._get_actions(instance)
        return context
Example #8
0
    def get_context_data(self, **kwargs):
        context = super(DetailView, self).get_context_data(**kwargs)
        instance = self.get_data()
        if instance.image:
            instance.image_url = reverse(self.image_url,
                                         args=[instance.image['id']])
        instance.volume_url = self.volume_url
        context["instance"] = instance
        context["url"] = get_url_with_pagination(
            self.request,
            project_tables.InstancesTable._meta.pagination_param,
            project_tables.InstancesTable._meta.prev_pagination_param,
            self.redirect_url)

        context["actions"] = self._get_actions(instance)
        return context
Example #9
0
def get_server_detail_link(obj, request):
    return get_url_with_pagination(request,
                                   InstancesTable._meta.pagination_param,
                                   InstancesTable._meta.prev_pagination_param,
                                   'horizon:project:instances:detail', obj.id)
Example #10
0
def get_server_detail_link(obj, request):
    return get_url_with_pagination(
        request, AdminInstancesTable._meta.pagination_param,
        AdminInstancesTable._meta.prev_pagination_param,
        "horizon:admin:instances:detail", obj.id)
Example #11
0
 def test_get_url_with_pagination_with_if(self):
     req = self.request
     url_string = 'horizon:project:instances:detail'
     url = views.get_url_with_pagination(req, None, None, url_string, 'id')
     self.assertEqual('/project/instances/id/', url)
Example #12
0
 def test_get_url_with_pagination(self):
     req = self.request
     url_string = 'horizon:project:instances:index'
     url = views.get_url_with_pagination(req, None, None, url_string, None)
     self.assertEqual('/project/instances/', url)
Example #13
0
def get_server_detail_link(obj, request):
    return get_url_with_pagination(request,
                                   InstancesTable._meta.pagination_param,
                                   InstancesTable._meta.prev_pagination_param,
                                   'horizon:project:instances:detail',
                                   obj.id)
Example #14
0
def get_server_detail_link(obj, request):
    return get_url_with_pagination(
        request, AdminInstancesTable._meta.pagination_param,
        AdminInstancesTable._meta.prev_pagination_param,
        "horizon:admin:instances:detail", obj.id)
Example #15
0
 def test_get_url_with_pagination_with_if(self):
     req = self.request
     url_string = 'horizon:project:instances:detail'
     url = views.get_url_with_pagination(req, None, None, url_string, 'id')
     self.assertEqual(six.text_type('/project/instances/id/'), url)