Beispiel #1
0
    def validate(self):
        from eve.views import char_in_corps
        from corp.models import DepartedMember

        if not char_in_corps(self.corporation_id):
            DepartedMember.objects.create(
                name="Character: %s" % self.name,
                corporation=self.corporation_name,
                reason="Automatic: member not in corporation",
                date=datetime.date.today(),
            )
            user = self.account.user_name
            user_profile = user.get_profile()
            if self == user_profile.main_char:
                other_accounts = user.user_account.exclude(id=self.account_id)
                if other_accounts.exists():
                    user_profile.main_char = other_accounts.latest("id").account_character.latest("id")
                    user_profile.save()
                else:
                    if TS:
                        for ts in user.teamspeak_account.all():
                            ts.delete()
                    user.is_active = False
                    user.save()
                    return False
            return False
        else:
            return True
Beispiel #2
0
def validate_form(data):
    check = False
    data['corp'] = False
    try:
        verify = views.key_info(data['keyid'], data['vcode'])
    except:
        raise forms.ValidationError('Authentication failure! check keyID, vCode pair')
    if not verify.key.expires == '':
        raise forms.ValidationError('Key expired! Please generate not expired key')
    if verify.key.type in ('Character', 'Account'):
        if not verify.key.accessMask == VALID_MASK:
            raise forms.ValidationError('Wrong access mask, please generate API key with "268435455" access mask')
    else:
        if verify.key.type == 'Corporation':
            if verify.key.accessMask == DIR_MASK:
                data['corp'] = True
            else:
                raise forms.ValidationError('Wrong access mask, please generate API key with "67108863" access mask')
        else:
            check = True
    for cur in verify.key.characters:
        if not data['corp']:
            if Character.objects.filter(name=cur.characterName).exists():
                raise forms.ValidationError('This API already in database!')
        if views.char_in_corps(cur.corporationID):
            check = True
            data['corp_id'] = cur.corporationID
    if not check:
        raise forms.ValidationError('You have not a valid characters!')
    return data
Beispiel #3
0
    def char_init(self):
        from eve.views import chars_info, char_in_corps

        char_info = chars_info(self.key_id, self.v_code)
        for char in char_info.characters:
            if char_in_corps(char.corporationID):
                Character.objects.create(
                    account=self,
                    name=char.name,
                    character_id=char.characterID,
                    corporation_name=char.corporationName,
                    corporation_id=char.corporationID,
                )