Compare commits

...

3 Commits

Author SHA1 Message Date
janko 774d269d91 yet another attempt to fix the scheduling bug 2022-10-31 18:24:47 +01:00
janko 8b115c98ad cleanup 2022-10-31 18:23:00 +01:00
janko a5de5f9e35 cleanup 2022-10-31 18:22:26 +01:00
7 changed files with 20 additions and 29 deletions

View File

@ -12,16 +12,12 @@ options = {
}
client = Client(options)
print(dir(client))
def get_file_list():
return client.list("/GIA CLOUD")
for file in get_file_list():
link = client.get_url(file)
print(link)
link = client.get_url(file)
info = client.info("/GIA CLOUD")
info = client.info("/GIA CLOUD")

View File

@ -14,8 +14,6 @@ name = seznam[0].get_name()
public_share = nc.share_file_with_link("/GIA CLOUD/"+name)
public_link= public_share.get_link()+"/download/"+name
print(public_link)
def test_file():
return public_link

View File

@ -17,7 +17,6 @@ def index():
if 'user_id' in session:
user_id = session['user_id']
username = session['username']
print(username)
status = schedule_status(user_id)
user_settings = get_settings(user_id)
@ -25,7 +24,7 @@ def index():
max_due = int(user_settings["max_due"])
total_new = len(list_of_new_cards_by_ids(user_id))
total_due = len(list_of_due_cards_by_ids(user_id)) - total_new
total_due = len(list_of_due_cards_by_ids(user_id))
rated_today_new = rated_today_by_staus("new", user_id)
rated_today_due = rated_today_by_staus("due", user_id)
remaining_new_today = remaining_items(max_new, total_new, rated_today_new)
@ -33,13 +32,10 @@ def index():
if request.method == "POST":
action = request.form.get("menu", False) #internetna rešitev, nevem kako, ampak dela, tj. dobi info iz meni buttonov
print(action)
if action == "new_session":
#preverimo če so sploh karte v collectionu
print("userID", user_id)
c = dbsession.query(Card).filter(Card.owner_id == user_id).all()
if c == []:
print("ne najdem collectiona")
return render_template("error/no_cards_in_collection.html", username=username)
return redirect(url_for("deck"))

View File

@ -13,9 +13,7 @@ def get_settings(user_id):
#tu rešujejo none user bug, ki se pojavi, ko na novo reg user, ni zazznan v querryju
# zdaj imamo problem clasha med globalno in lokalno spremenljivko "dbsession"
if user == None:
print("user je bil none")
user = dbsession.query(User).get(user_id)
print("User je: ", user)
settings_db = user.settings
if settings_db == "":
@ -29,7 +27,6 @@ def get_settings(user_id):
settings_dict = json.loads(settings_db)
dbsession.close()
print("this is it: ", settings_dict)
return settings_dict
@ -47,8 +44,6 @@ def save_settings():
return render_template("settings.html", username=username, settings=settings_old)
if request.method == "POST":
print('this is the form ', request.form)
#request form stuff
settings_dict = {
"max_new" : request.form.get('max_new', False),
@ -56,9 +51,7 @@ def save_settings():
"max_shared" : request.form.get('max_shared', False),
}
print('this is the dict: ', settings_dict)
settings_json = json.dumps(settings_dict)
print('this is the json: ', settings_json)
user = dbsession.query(User).get(user_id)
user.settings = settings_json

View File

@ -23,7 +23,6 @@ def share(card, user_id):
#skip če že ima ta card v db.
existing = dbsession.query(Card).filter(Card.title == card.title, Card.owner_id==user.id).all()
if existing == []:
print("sharing to, ", user.id)
new_card = card = Card(title=card.title, interest_rate=-1.0, owner_id=user.id, item_location=card.item_location, last_review=None, share_id=h)
dbsession.add(new_card)
dbsession.commit()
@ -31,7 +30,6 @@ def share(card, user_id):
def get_all_shared(user_id):
"""adds all existing shared cards to this users collection"""
print("DODAJAMO VSE KARTE TEMU NOVEMU USERJU")
dbsession = get_session()
#get all cards with a shared id but make suer they are unique. add them to collection of user
@ -41,5 +39,4 @@ def get_all_shared(user_id):
for c in all_shared_cards:
new_card = Card(title= c.title, interest_rate=-1.0, owner_id=user_id, item_location=c.item_location, last_review=None, share_id=c.share_id)
dbsession.add(new_card)
dbsession.commit()
print(c.title, c.share_id, c.item_location)
dbsession.commit()

View File

@ -70,13 +70,26 @@ def is_due(card_id):
dbsession.close()
return date.today() >= due_date
def is_new(card_id):
dbsession = get_session()
rating = dbsession.query(Rating).filter(Rating.card_id == card_id).first()
dbsession.close()
if rating == None:
return True
else:
return False
def list_of_due_cards_by_ids(user_id):
"this should not include new cards"
dbsession = get_session()
cards = dbsession.query(Card).filter(Card.owner_id == user_id).all()
l = []
for card in cards:
if is_due(card.id):
if is_new(card.id):
pass
elif is_due(card.id):
l.append(card.id)
dbsession.close()
return l
@ -158,7 +171,7 @@ def schedule_status(user_id):
rated_due = rated_today_by_staus("due", user_id)
total_new = len(list_of_new_cards_by_ids(user_id))
total_due = len(list_of_due_cards_by_ids(user_id)) - total_new
total_due = len(list_of_due_cards_by_ids(user_id))
remaining_new_today = remaining_items(max_new, total_new, rated_new)
remaining_due_today = remaining_items(max_due, total_due, rated_due)
@ -222,7 +235,7 @@ def sr_session():
max_due = int(user_settings["max_due"])
total_new = len(list_of_new_cards_by_ids(user_id))
total_due = len(list_of_due_cards_by_ids(user_id)) - total_new
total_due = len(list_of_due_cards_by_ids(user_id))
rated_today_new = rated_today_by_staus("new", user_id)
rated_today_due = rated_today_by_staus("due", user_id)

View File

@ -16,7 +16,6 @@ bp = Blueprint('upload', __name__, url_prefix='/upload')
nc = nextcloud_client.Client('https://obzorje.kompot.si')
#print("Loggin in", CONFIG['NC_USER'], CONFIG['NC_PASSWORD'])
nc.login(CONFIG['NC_USER'],CONFIG['NC_PASSWORD'])
@ -43,7 +42,6 @@ def upload_file():
return render_template("upload.html", username=username)
#prevent duplicate filenames
print(filename)
if dbsession.query(Card).filter(Card.title == filename).first() != None:
flash("Filename already in database, please rename if you want to upload: " + filename, 'error')
continue