Pi 4 сар өмнө
parent
commit
7bb0f96986

+ 1 - 1
rest/bar.py

@@ -1,6 +1,6 @@
 from barcode import EAN13
 
 def get_bar_code(meta):
-    if meta['type'] == 'EAN13':
+    if meta['format'] == 'EAN_13':
         return EAN13(meta['content']).render()
     return None

+ 3 - 3
rest/pyapi.py

@@ -63,9 +63,9 @@ def get_goto_preview():
     except:
         return dumps(None)
 
-@route('/code/preview', method=['GET'])
+@route('/code/preview', method=['POST'])
 def get_code_preview():
-    body = request.body
+    body = load(request.body)
     response.content_type = 'image/svg+xml'
     if not body:
         abort(404, 'Empty request')
@@ -74,7 +74,7 @@ def get_code_preview():
 
 
 @route('/<route:re:(clip|goto|upload|code)>/hash', method=['POST'])
-def get_hash():
+def get_hash(route):
     body = load(request.body)
     data = body['data']
     person = body.get('person', None)

+ 1 - 1
util-sqlpage/code/new.sql

@@ -1,5 +1,5 @@
 INSERT INTO code(hash, content, svg, created)
-VALUES ($hash, $content, $qr, CURRENT_TIMESTAMP)
+VALUES ($hash, $content, $preview, CURRENT_TIMESTAMP)
 ON CONFLICT DO
 UPDATE SET
   content = excluded.content,

+ 3 - 3
util-sqlpage/code/recent.sql

@@ -28,14 +28,14 @@ ON c.hash = cd.hash
 WHERE (
     cd.expiry IS NULL OR COALESCE($expired, 'false') = 'true' OR date(cd.expiry) > date(datetime(CURRENT_TIMESTAMP, 'localtime'))
 ) AND (
-    cd.used IS NULL OR COALESCE($used, 'false') = 'true' OR cd.used||'' = 'false'
+    cd.used IS NULL OR COALESCE($used||'', 'false') = 'true' OR COALESCE(cd.used||'','') = 'false'
 ) AND (
-    cd.type IS NULL OR CASE COALESCE($type, '')
+    CASE COALESCE($type, '')
       WHEN '' THEN TRUE
       ELSE $type = cd.type
     END
 ) AND (
-    cd.store IS NULL OR CASE COALESCE($store, '')
+    CASE COALESCE($store, '')
       WHEN '' THEN TRUE
       ELSE $store = cd.store
     END

+ 1 - 1
util-sqlpage/code/save.sql

@@ -14,5 +14,5 @@ SET ":request" = json_object(
     'headers', json_object(),
     'body', $content
 );
-SET ":qr" = sqlpage.fetch($request);
+SET ":preview" = sqlpage.fetch($request);
 SELECT 'dynamic' AS component, sqlpage.run_sql('code/new.sql') AS properties;