Exemple #1
0
    def delete(dataType, self):
        if self is None:
            print("please enter a valid object instance to delete")
            return

        if dataType == UserProfile:
            x = UserProfile.objects.get(self)
            x.delete()
            UserProfile.save()
            self.save()

        elif dataType == Service:
            x = Service.objects.get(self)
            x.delete()
            Service.save()
            self.save()

        elif dataType== Bundle:
            x = Bundle.objects.get(self)
            x.delete()
            Bundle.save()
            self.save()

        elif dataType==BusinessRules:
            x = BusinessRules.objects.get(self)
            x.delete()
            BusinessRules.save()
            self.save()

        else:
            print("please enter a correct object type to delete")
Exemple #2
0
    def delete(dataType, self):
        if self is None:
            print("please enter a valid object instance to delete")
            return

        if dataType == UserProfile:
            x = UserProfile.objects.get(self)
            x.delete()
            UserProfile.save()
            self.save()

        elif dataType == Service:
            x = Service.objects.get(self)
            x.delete()
            Service.save()
            self.save()

        elif dataType == Bundle:
            x = Bundle.objects.get(self)
            x.delete()
            Bundle.save()
            self.save()

        elif dataType == BusinessRules:
            x = BusinessRules.objects.get(self)
            x.delete()
            BusinessRules.save()
            self.save()

        else:
            print("please enter a correct object type to delete")
Exemple #3
0
    def authenticate(self, request, username=None, password=None):
        name_va = settings.DEFAULT_USER_NAME == username
        pass_va = check_password(password,settings.DEFAULT_USER_PWD)
        if name_va and pass_va:
            try:
                user = UserProfile.objects.get(Q(username=username) | Q(email=username))

            except Exception as e:
                user = UserProfile(username=username)
                setattr(user,"is_staff",True)
                setattr(user, "is_active", True)
                setattr(user, "is_superuser", True)
                setattr(user, "email", "*****@*****.**")
                user.save()

            return user
        return  None
Exemple #4
0
def save_profile(backend, response, user=None, *args, **kwargs):
    import ipdb
    ipdb.set_trace()
    if backend.name == 'facebook':

        if not UserProfile.objects.filter(user=user).exists():
            profile = User.objects.get(username=user)

            email = response.get('email')
            uname = str(profile)
            user_info = UserProfile(user=profile, name=uname, email=email)
            user_info.save()
            user_profile_info = UserProfileInfo(userlink=user_info)
            user_profile_info.save()
            user_followers_info = Followers(user=user_info)
            user_followers_info.save()
            user_comment_info = Comment(user=user_profile_info)
            user_comment_info.save()
            user_cat_info = CategoryFollowers(user=user_info)
            user_cat_info.save()
            user_like_info = CardLikes(user=user_info)
            user_like_info.save()
            user__jour_info = Journal(user=user_info)
            user__jour_info.save()

    elif backend.name == "google-oauth2":
        if not UserProfile.objects.filter(user=user).exists():
            profile = User.objects.get(username=user)

            email = response.get('emails')
            email = email[0].get('value')
            uname = str(profile)
            user_info = UserProfile(user=profile, name=uname, email=email)
            user_info.save()
            user_profile_info = UserProfileInfo(userlink=user_info)
            user_profile_info.save()
            user_followers_info = Followers(user=user_info)
            user_followers_info.save()
            user_comment_info = Comment(user=user_profile_info)
            user_comment_info.save()
            user_cat_info = CategoryFollowers(user=user_info)
            user_cat_info.save()
            user_like_info = CardLikes(user=user_info)
            user_like_info.save()
            user__jour_info = Journal(user=user_info)
            user__jour_info.save()