import os, sys
cur_dir = os.path.dirname(__file__)
sys.path.append(os.path.dirname(cur_dir))
from fwd_api.models.UserProfile import UserProfile
from fwd_api.models.SubscriptionRequest import SubscriptionRequest
from fwd_api.models.Subscription import Subscription
from fwd_api.models.PricingPlan import PricingPlan

import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fwd.settings")
django.setup()

def add_user(user_name, user_id, _sync_id, sub_id, price_id, page_limit=100000000, day_count=1000000000):
    print(f"[INFO]: Creating user {user_name} with id: {user_id}")
    user = UserProfile(id=user_id, full_name=user_name, sync_id=_sync_id, current_total_pages=0, limit_total_pages=page_limit, status=1)
    pricing = PricingPlan(id=price_id, token_limitations=page_limit, duration=day_count)
    sub = Subscription(id=sub_id, current_token=0, limit_token=page_limit, pricing_plan=pricing, user=user, expired_at="2099-01-01 01:01", status=1)
    pricing.save()
    user.save()
    sub.save()
    print("[INFO]: User added")

def main(user_name, user_id, _sync_id, sub_id, price_id, page_limit=100000000, day_count=1000000000):
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fwd.settings.local")
    django.setup()
    add_user(user_name, user_id, _sync_id, sub_id, price_id, page_limit, day_count)

# if __name__=="__main__":
main("TannedCung", user_id=1, price_id=36, sub_id=33, _sync_id="xhuyen")