示例#1
0
    def create_local(self):
        perm = UserLocationPermission()
        perm.account = self.validated_data.get('account')
        perm.country = self.validated_data.get('country')
        perm.station = self.validated_data.get('station')
        perm.permission = self.validated_data.get('permission')

        return perm
示例#2
0
    def add_permission(user, permission_configuration):
        for config in permission_configuration:
            perm = Permission.objects.get(permission_group=config['group'],
                                          action=config['action'])

            ulp = UserLocationPermission()
            ulp.account = user
            ulp.permission = perm
            ulp.country = config['country']
            ulp.station = config['station']
            ulp.save()
示例#3
0
 def create(permission_configuration):
     user = GenericUser.create()
     for config in permission_configuration:
         perm = Permission.objects.get(permission_group=config['group'], action=config['action'])
         
         ulp = UserLocationPermission()
         ulp.account = user
         ulp.permission = perm
         ulp.country = config['country']
         ulp.station = config['station']
         ulp.save()
     
     return user
    def setUp(self):
        user = SuperUserFactory.create()
        self.client = APIClient()
        self.client.force_authenticate(user=user)

        self.globalCount += 1
        self.nepal = self.get_or_create_country('Nepal')
        self.south_africa = self.get_or_create_country('South Africa')
        self.thailand = self.get_or_create_country('Thailand')

        self.nepal_bs1 = self.get_or_create_station("nepal1", "NP1",
                                                    self.nepal)
        self.nepal_bs2 = self.get_or_create_station("nepal2", "NP2",
                                                    self.nepal)
        self.nepal_bs3 = self.get_or_create_station("nepal3", "NP3",
                                                    self.nepal)
        self.south_africa_bs = self.nepal_bs3 = self.get_or_create_station(
            "sa", "SA1", self.south_africa)
        self.thailand_bs = self.nepal_bs3 = self.get_or_create_station(
            "thai", "TL1", self.thailand)

        self.account = SuperUserFactory.create()

        self.permissions = []

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = None
        tmp.station = None
        tmp.permission = Permission.objects.get(permission_group='IRF',
                                                action='VIEW')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = None
        tmp.station = self.nepal_bs2
        tmp.permission = Permission.objects.get(permission_group='IRF',
                                                action='ADD')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = None
        tmp.station = self.thailand_bs
        tmp.permission = Permission.objects.get(permission_group='IRF',
                                                action='ADD')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = None
        tmp.station = self.nepal_bs2
        tmp.permission = Permission.objects.get(permission_group='IRF',
                                                action='EDIT')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = None
        tmp.station = self.thailand_bs
        tmp.permission = Permission.objects.get(permission_group='IRF',
                                                action='EDIT')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = self.nepal
        tmp.station = None
        tmp.permission = Permission.objects.get(permission_group='VIF',
                                                action='VIEW')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = self.nepal
        tmp.station = None
        tmp.permission = Permission.objects.get(permission_group='VIF',
                                                action='ADD')
        tmp.save()
        self.permissions.append(tmp)

        tmp = UserLocationPermission()
        tmp.account = self.account
        tmp.country = self.nepal
        tmp.station = None
        tmp.permission = Permission.objects.get(permission_group='VIF',
                                                action='EDIT')
        tmp.save()
        self.permissions.append(tmp)