示例#1
0
    def delete(self, request, groupname):
        with self._handle_exception(request):
            if (groupname in self.exclude_list):
                e_msg = ('Delete of restricted group(%s) is not supported.' %
                         groupname)
                handle_exception(Exception(e_msg), request)

            if (Group.objects.filter(groupname=groupname).exists()):
                g = Group.objects.get(groupname=groupname)
                g.delete()
            else:
                found = False
                for g in combined_groups():
                    if (g.groupname == groupname):
                        found = True
                        break
                if (found is False):
                    e_msg = ('Group(%s) does not exist' % groupname)
                    handle_exception(Exception(e_msg), request)

            try:
                groupdel(groupname)
            except Exception, e:
                handle_exception(e, request)

            return Response()
示例#2
0
    def delete(self, request, groupname):
        with self._handle_exception(request):
            if (groupname in self.exclude_list):
                e_msg = ('Delete of restricted group(%s) is not supported.' %
                         groupname)
                handle_exception(Exception(e_msg), request)

            if (Group.objects.filter(groupname=groupname).exists()):
                g = Group.objects.get(groupname=groupname)
                g.delete()
            else:
                found = False
                for g in combined_groups():
                    if (g.groupname == groupname):
                        found = True
                        break
                if (found is False):
                    e_msg = ('Group(%s) does not exist' % groupname)
                    handle_exception(Exception(e_msg), request)

            try:
                groupdel(groupname)
            except Exception, e:
                handle_exception(e, request)

            return Response()
示例#3
0
    def delete(self, request, groupname):
        with self._handle_exception(request):
            if groupname in self.exclude_list:
                e_msg = ("Delete of restricted group ({}) is not supported."
                         ).format(groupname)
                handle_exception(Exception(e_msg), request, status_code=400)

            if Group.objects.filter(groupname=groupname).exists():
                g = Group.objects.get(groupname=groupname)
                g.delete()
            else:
                found = False
                for g in combined_groups():
                    if g.groupname == groupname:
                        found = True
                        break
                if found is False:
                    e_msg = "Group ({}) does not exist.".format(groupname)
                    handle_exception(Exception(e_msg), request)

            try:
                groupdel(groupname)
            except Exception as e:
                handle_exception(e, request)

            return Response()
示例#4
0
 def test_group_4(self):
     """
     group in db but deleted manually in the system
     """
     data = {'groupname': 'rocky', }
     self.client.login(username='******', password='******')
     response = self.client.post(self.BASE_URL, data=data)
     self.assertEqual(response.status_code, status.HTTP_200_OK,
                      msg=response.content)
     from system.users import groupdel
     groupdel(data['groupname'])
     response2 = self.client.delete('%s/rocky' % self.BASE_URL)
     self.assertEqual(response2.status_code,
                      status.HTTP_200_OK,
                      msg=response2.content)
示例#5
0
 def test_group_4(self):
     """
     group in db but deleted manually in the system
     """
     data = {
         'groupname': 'rocky',
     }
     self.client.login(username='******', password='******')
     response = self.client.post(self.BASE_URL, data=data)
     self.assertEqual(response.status_code,
                      status.HTTP_200_OK,
                      msg=response.content)
     from system.users import groupdel
     groupdel(data['groupname'])
     response2 = self.client.delete('%s/rocky' % self.BASE_URL)
     self.assertEqual(response2.status_code,
                      status.HTTP_200_OK,
                      msg=response2.content)