You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from django.contrib.auth.models import User
for i in range(1,10):
User.objects.create(username='Asad'+str(i),password='123', email='asad@test'+str(i)+'.com')
Create a shell script to import Maus:
import random
import time
from django.contrib.auth.models import User
from edly_panel_app.models import EdlyUserActivity
def str_time_prop(start, end, format, prop):
"""Get a time at a proportion of a range of two formatted times.
start and end should be strings specifying times formated in the
given format (strftime-style), giving an interval [start, end].
prop specifies how a proportion of the interval to be taken after
start. The returned time will be in the specified format.
"""
stime = time.mktime(time.strptime(start, format))
etime = time.mktime(time.strptime(end, format))
ptime = stime + prop * (etime - stime)
return time.strftime(format, time.localtime(ptime))
def random_date(start, end, prop):
return str_time_prop(start, end, '%Y-%m-%d', prop)
def enter_each_user_activity():
from openedx.features.edly.models import EdlySubOrganization
edly_sub_org = EdlySubOrganization.objects.get(id=1)
for i in range(10):
users = User.objects.all()
for user in users:
try:
EdlyUserActivity.objects.create(user=user, edly_sub_organization=edly_sub_org)
except:
pass
activities = EdlyUserActivity.objects.all()
for activity in activities:
try:
activity.activity_date = random_date('2010-01-01', '2020-01-01', random.random())
activity.save()
except:
pass
Import maus data using script
from edly_panel_app.data_import_script import enter_each_user_activity
enter_each_user_activity()