Browse Source

Move model to cleanup

Eren Yilmaz 5 năm trước cách đây
mục cha
commit
45bea8aa33
9 tập tin đã thay đổi với 15 bổ sung11 xóa
  1. 1 3
      create_new_key.py
  2. 1 1
      create_new_stock.py
  3. 1 1
      delete_ownable.py
  4. 1 1
      delete_user.py
  5. 1 1
      drop_old_sessions.py
  6. 1 1
      hash_all_users_passwords.py
  7. 7 1
      model.py
  8. 1 1
      publish_news_item.py
  9. 1 1
      reset_bank.py

+ 1 - 3
create_new_key.py

@@ -1,7 +1,5 @@
-from admin_console import cleanup
-from model import generate_keys, unused_keys
+from model import generate_keys, cleanup
 
 if __name__ == '__main__':
     generate_keys(count=1)
-    print(unused_keys())
     cleanup()

+ 1 - 1
create_new_stock.py

@@ -2,7 +2,7 @@ from datetime import timedelta
 from time import strptime
 
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     timeout = float(input('How long will the initial selling be available? (minutes):'))

+ 1 - 1
delete_ownable.py

@@ -1,5 +1,5 @@
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     ownable_id = model.ownable_id_by_name(input('Which ownable?'))

+ 1 - 1
delete_user.py

@@ -1,5 +1,5 @@
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     user_id = model.get_user_id_by_name(input('Which user?'))

+ 1 - 1
drop_old_sessions.py

@@ -1,5 +1,5 @@
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     model.drop_old_sessions()

+ 1 - 1
hash_all_users_passwords.py

@@ -1,5 +1,5 @@
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     if input('Are you sure you want to hash all users passwords? (type in "yes" or something else):') == 'yes':

+ 7 - 1
model.py

@@ -1094,4 +1094,10 @@ def reset_bank():
     cursor.execute('''
         DELETE FROM ownership 
         WHERE user_id = ?
-        ''', (bank_id(),))
+        ''', (bank_id(),))
+
+
+def cleanup():
+    if connection is not None:
+        connection.commit()
+        connection.close()

+ 1 - 1
publish_news_item.py

@@ -1,5 +1,5 @@
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     print(model.new_news(input('Message of the news:')))

+ 1 - 1
reset_bank.py

@@ -1,5 +1,5 @@
 import model
-from admin_console import cleanup
+from model import cleanup
 
 if __name__ == '__main__':
     if input('Are you sure you want to remove all the banks ownerships? (type in "yes" or something else):') == 'yes':