sync from local backup
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import django, os
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'chunyu_project.settings'
|
||||
django.setup()
|
||||
from django.utils import timezone
|
||||
from django.core.cache import cache
|
||||
from user.models import DailyCheckin, FUser, PointTransaction
|
||||
|
||||
cache.clear()
|
||||
today = timezone.localdate()
|
||||
DailyCheckin.objects.filter(checkin_date=today).delete()
|
||||
PointTransaction.objects.all().delete()
|
||||
for uid in [1, 2, 3, 4]:
|
||||
try:
|
||||
u = FUser.objects.get(id=uid)
|
||||
u.points = 0
|
||||
u.save()
|
||||
except FUser.DoesNotExist:
|
||||
pass
|
||||
print("Data reset done")
|
||||
|
||||
import requests, json
|
||||
from rest_framework_simplejwt.tokens import AccessToken
|
||||
|
||||
user = FUser.objects.get(id=2)
|
||||
token = str(AccessToken.for_user(user))
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
print("\n=== 1. Get status BEFORE checkin ===")
|
||||
r = requests.get("http://127.0.0.1:8000/user/wallet/checkin/status/", headers=headers)
|
||||
print(f"HTTP {r.status_code}")
|
||||
d = r.json()
|
||||
print(f"Response: {json.dumps(d, indent=2, ensure_ascii=False)}")
|
||||
|
||||
print("\n=== 2. Do checkin ===")
|
||||
r = requests.post("http://127.0.0.1:8000/user/wallet/checkin/", headers=headers)
|
||||
print(f"HTTP {r.status_code}")
|
||||
d = r.json()
|
||||
print(f"Response: {json.dumps(d, indent=2, ensure_ascii=False)}")
|
||||
|
||||
print("\n=== 3. Get status AFTER checkin ===")
|
||||
r = requests.get("http://127.0.0.1:8000/user/wallet/checkin/status/", headers=headers)
|
||||
print(f"HTTP {r.status_code}")
|
||||
d = r.json()
|
||||
print(f"Response: {json.dumps(d, indent=2, ensure_ascii=False)}")
|
||||
|
||||
print("\n=== 4. Get status AGAIN (simulating re-entering page) ===")
|
||||
r = requests.get("http://127.0.0.1:8000/user/wallet/checkin/status/", headers=headers)
|
||||
print(f"HTTP {r.status_code}")
|
||||
d = r.json()
|
||||
print(f"Response: {json.dumps(d, indent=2, ensure_ascii=False)}")
|
||||
Reference in New Issue
Block a user