示例#1
0
    def create_guestuser(self):
        guest = User()
        guest.username = '******'
        guest.first_name = 'Guest'
        guest.last_name = 'User'
        guest.set_password('guest')
        guest.is_staff = True
        guest.save()

        # add permissions
        for table in ['session', 'collection', 'userprofile', 'deviceprofile']:
            for code in ['add', 'change', 'delete']:
                code_name = code + '_' + table
                permission = Permission.objects.get(codename=code_name)
                guest.user_permissions.add(permission)

        # create default model
        profile = UserProfile(user=guest, module='ietf-interfaces@2013-12-23')
        profile.save()

        # add default collection
        col = Collection(name='default',
                         user=guest,
                         description='Default Collection')
        col.save()
示例#2
0
    def create_guestuser(self, cxmldir):
        guest = User()
        guest.username = '******'
        guest.first_name = 'Guest'
        guest.last_name = 'User'
        guest.set_password('guest')
        guest.is_staff = True
        guest.save()

        # add permissions
        for table in ['session', 'collection', 'userprofile', 'deviceprofile']:
            for code in ['add', 'change', 'delete']:
                code_name = code + '_' + table
                permission = Permission.objects.get(codename=code_name)
                guest.user_permissions.add(permission)

        # create list of model
        if cxmldir:
            for f in os.listdir(cxmldir):
                f_split = os.path.splitext(f)
                if f_split[1] == '.xml':
                    profile = UserProfile(user=guest,
                                          module=os.path.basename(f_split[0]))
                    profile.save()
        else:
            profile = UserProfile(user=guest,
                                  module='ietf-interfaces@2013-12-23')
            profile.save()

        # add default collection
        col = Collection(name='default',
                         user=guest,
                         description='Default Collection')
        col.save()
示例#3
0
 def setUp(self):
     demo = User()
     demo.username = '******'
     demo.first_name = 'Demo'
     demo.last_name = 'Last'
     demo.set_password('demo123')
     demo.is_staff = False
     demo.save()
     self.user = demo
     self.user_path = os.path.join('data', 'users', 'demo')
     self.chrome = Client()
     self.upload_files = []
示例#4
0
    def create_guestuser(self):
        guest = User()
        guest.username = '******'
        guest.first_name = 'Guest'
        guest.last_name = 'User'
        guest.set_password('guest')
        guest.is_staff = True
        guest.save()

        # add permissions
        for table in ['session', 'collection', 'userprofile', 'deviceprofile']:
            for code in ['add', 'change', 'delete']:
                code_name = code + '_' + table
                permission = Permission.objects.get(codename=code_name)
                guest.user_permissions.add(permission)

        # create default model
        profile = UserProfile(user=guest, module='ietf-interfaces@2013-12-23')
        profile.save()

        # add default collection
        col = Collection(name='default', user=guest, description='Default Collection')
        col.save()