Exemple #1
0
    def get_api_key(self):
        apikey = ApiKey.objects.filter(user=self.user)
        key = ""
        if apikey and apikey.count > 0:
            key = apikey[0].key
        else:
            key_obj = ApiKey()
            key_obj.user = self.user
            key_obj.save()
            keys = ApiKey.objects.filter(user=self.user)
            if keys.count > 0:
                key = keys[0].key

        return key
Exemple #2
0
	def get_api_key(self):
		apikey = ApiKey.objects.filter(user=self.user)
		key = ""
		if apikey and apikey.count > 0:
			key = apikey[0].key
		else:
			key_obj = ApiKey()
			key_obj.user = self.user
			key_obj.save()
			keys = ApiKey.objects.filter(user=self.user)
			if keys.count > 0:
				key = keys[0].key

		return key
Exemple #3
0
 def setUpClass(cls):
     cls.factory = RequestFactory()
     cls.first=ModpackCache(name='test_d',slug='test',url='http://nope.org',description='test',logo_md5='',icon_md5='', background_md5='')
     cls.first.save()
     tmp= VersionCache(version='1.0', recommended=True, latest=False, modpack=cls.first, mcversion='1.6.4',forgever='nover')
     tmp.save()
     VersionCache(version='1.1dev', recommended=False, latest=True,modpack=cls.first, mcversion='1.6.4',forgever='').save()
     t = ModInfoCache(name='mod',pretty_name='pretty_mod',author='me',description='mod_d',link='http://nope.org')
     t.save()
     m = ModCache(localpath='/etc/issue',version='1.0',modInfo=t,md5='somemd5', type='universal')
     m.save()
     m = ModCache(localpath='/etc/issue2',version='1.2',modInfo=t,md5='somemd52', type='universal')
     m.save()
     tmp.mods.add(m)
     t = ModInfoCache(name='mod2',pretty_name='pretty_mod2',author='me2',description='mod_d2',link='http://nope2.org')
     t.save()
     m = ModCache(localpath='/etc/issue3',version='1.03',modInfo=t, md5='somemd53', type='universal')
     m.save()
     ModpackCache(name='test2',slug='test2',url='http://nope.org',description='test2',logo_md5='',icon_md5='', background_md5='').save()
     tmp.mods.add(m)
     ApiKey(key='somekey',description='mykey').save()
     ApiKey(key='somekey2',description='mykey').save()
Exemple #4
0
    def save(self):
        username = self.cleaned_data['username']
        email = self.cleaned_data['email']
        password = self.cleaned_data['password']

        user = User.objects.create_user(username, email, password)
        user.is_staff = False
        user.first_name = self.cleaned_data['firstname']
        user.last_name = self.cleaned_data['lastname']
        user.save()

        api_key = ApiKey()
        api_key.userid = self.cleaned_data['api_userid']
        api_key.vcode = self.cleaned_data['api_vcode']
        api_key.user = user
        api_key.primary_api_key = True
        api_key.valid = False
        api_key.save()

        profile = user.get_profile()
        #profile.member_type = self.cleaned_data['member_type']
        profile.save()

        return user
Exemple #5
0
    def save(self):
        username = self.cleaned_data["username"]
        email = self.cleaned_data["email"]
        password = self.cleaned_data["password"]

        user = User.objects.create_user(username, email, password)
        user.is_staff = False
        user.first_name = self.cleaned_data["firstname"]
        user.last_name = self.cleaned_data["lastname"]
        user.save()

        api_key = ApiKey()
        api_key.userid = self.cleaned_data["api_userid"]
        api_key.vcode = self.cleaned_data["api_vcode"]
        api_key.user = user
        api_key.primary_api_key = True
        api_key.valid = False
        api_key.save()

        profile = user.get_profile()
        # profile.member_type = self.cleaned_data['member_type']
        profile.save()

        return user
Exemple #6
0
 def setUpClass(cls):
     cls.factory = RequestFactory()
     ApiKey(key='testkey',description='mykey').save()
     ApiKey(key='testkey2',description='mykey').save()
Exemple #7
0
 def create_api_key(self, subscriber=None):
   if subscriber is None:
     subscriber = self.create_subscriber()
   api_key = ApiKey(api_key=self.randomString(), subscriber=subscriber)
   api_key.save()
   return api_key.api_key