]> WPIA git - motion.git/commitdiff
Merge branch 'admin_cleanup' into 'master'
authorFelix Dörre <felix@dogcraft.de>
Sun, 10 Jan 2021 22:16:14 +0000 (23:16 +0100)
committerFelix Dörre <felix@dogcraft.de>
Sun, 10 Jan 2021 22:16:14 +0000 (23:16 +0100)
add: implement motion cleanup

See merge request felixdoerre/motion!28

1  2 
motion.py
tests/test_basics.py
tests/test_motion.py

diff --cc motion.py
index 21e3e1605a39e9aa70c70e63613208a1acc47aa9,51ec30bc795d9782fce9eb6a1aed42e33d9c0c4d..c4337f98d4abe8f6c71d76f5f02e39b9ebac2482
+++ b/motion.py
@@@ -261,19 -261,13 +262,24 @@@ def init_db()
                  db.prepare("ALTER TABLE \"voter\" ALTER COLUMN \"host\" SET NOT NULL")()
                  db.prepare("UPDATE \"schema_version\" SET \"version\"=6")()
  
+         if ver < 7:
+             with app.open_resource('sql/from_6.sql', mode='r') as f:
+                 db.execute(f.read())
+                 db.prepare("UPDATE \"schema_version\" SET \"version\"=7")()
  init_db()
  
 +def is_in_ratelimit(group):
 +    rv = get_db().prepare("SELECT EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - posed)) AS timedifference FROM motion WHERE type=$1 AND host=$2 ORDER BY posed DESC LIMIT 1")(group, request.host)
 +    if len(rv) == 0:
 +        return True
 +    rate_limit = motion_wait_minutes.per_host
 +    if rate_limit is None:
 +        rate_limit = 0
 +    if rv[0]['timedifference'] > rate_limit*60:
 +        return True
 +    else:
 +        return _('Error, time between last motion to short. The current setting is %s minute(s).') % (str(rate_limit))
  
  @app.route("/")
  def main():
Simple merge
Simple merge