Archive deletion

Added archive deletion with a confirmation page
This commit is contained in:
Michael Rodin 2023-10-19 19:14:18 +02:00
parent f0b8b1eb3d
commit 82625c9d73
5 changed files with 439 additions and 41 deletions

View file

@ -38,15 +38,24 @@
<y:FreeNodePortLocationModelParameter x:Key="3" Ratio="0.007575757575757569,0.5"/>
<yjs:SolidColorFill x:Key="4" color="#FFCEDED3"/>
<yjs:SolidColorFill x:Key="5" color="#FFB7E3C5"/>
<yjs:SolidColorFill x:Key="6" color="#FF663800"/>
<yjs:Stroke x:Key="7" fill="{y:GraphMLReference 6}"/>
<yjs:Arrow x:Key="8" type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}" cropLength="1"/>
<yjs:PolylineEdgeStyle x:Key="9" stroke="{y:GraphMLReference 7}" targetArrow="{y:GraphMLReference 8}"/>
<yjs:Stroke x:Key="6" fill="#FF663800"/>
<y:ExteriorLabelModel x:Key="7" Insets="5"/>
<yjs:Font x:Key="8" fontSize="12"/>
<yjs:SolidColorFill x:Key="9" color="#FF663800"/>
<y:SmartEdgeLabelModelParameter x:Key="10" Distance="5">
<y:SmartEdgeLabelModelParameter.Model>
<y:SmartEdgeLabelModel/>
</y:SmartEdgeLabelModelParameter.Model>
</y:SmartEdgeLabelModelParameter>
<yjs:DefaultLabelStyle x:Key="11" verticalTextAlignment="CENTER" horizontalTextAlignment="CENTER" font="{y:GraphMLReference 8}" textFill="BLACK"/>
<yjs:Stroke x:Key="12" fill="{y:GraphMLReference 9}"/>
<yjs:Arrow x:Key="13" type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}" cropLength="1"/>
<yjs:PolylineEdgeStyle x:Key="14" stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}"/>
</y:SharedData>
</data>
<graph id="G" edgedefault="directed">
<data key="d6">
<y:Json>{"version":"2.0.0","origin":"yed-live","theme":{"name":"light","version":"1.0.0"}}</y:Json>
<y:Json>{"version":"2.0.0","origin":"yed-live","theme":{"name":"light","version":"1.0.0"},"layout":"layout-smart","config":{}}</y:Json>
</data>
<node id="n0">
<data key="d0">1</data>
@ -89,6 +98,11 @@
<y:FreeNodePortLocationModelParameter Ratio="0.5,0.007575757575757569"/>
</data>
</port>
<port name="p3">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.9924242424242424,0.5"/>
</data>
</port>
</node>
<node id="n1">
<data key="d0">2</data>
@ -122,6 +136,11 @@
<y:FreeNodePortLocationModelParameter Ratio="0.9924242424242424,0.5"/>
</data>
</port>
<port name="p2">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.9924242424242424,0.5"/>
</data>
</port>
</node>
<node id="n2">
<data key="d0">3</data>
@ -159,6 +178,11 @@
<y:FreeNodePortLocationModelParameter Ratio="0.5,0.9924242424242424"/>
</data>
</port>
<port name="p3">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.007575757575757569,0.5"/>
</data>
</port>
</node>
<node id="n3">
<data key="d0">4</data>
@ -186,6 +210,26 @@
<y:FolderNodeState x:Key="c|view" Layout="-27.5,-250,130,130"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.007575757575757569,0.5"/>
</data>
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
<port name="p1">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.9924242424242424,0.5"/>
</data>
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n4">
<data key="d0">6</data>
@ -287,6 +331,11 @@
<y:FreeNodePortLocationModelParameter Ratio="0.007575757575757569,0.5"/>
</data>
</port>
<port name="p3">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.007575757575757569,0.5"/>
</data>
</port>
</node>
<node id="n7">
<data key="d0">9</data>
@ -331,56 +380,373 @@
</y:FolderNodeState>
</y:ViewState>
</data>
<port name="p0">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.9924242424242424,0.5"/>
</data>
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
<port name="p1">
<data key="d16">
<y:FreeNodePortLocationModelParameter Ratio="0.007575757575757569,0.5"/>
</data>
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<edge id="e0" source="n0" target="n2" sourceport="p0" targetport="p0">
<data key="d10"><![CDATA[]]></data>
<node id="n8">
<data key="d0">17</data>
<data key="d4">
<x:List>
<y:Label>
<y:Label.Text>LEGEND</y:Label.Text>
<y:Label.LayoutParameter>
<y:GroupNodeLabelModelParameter PlaceOnTab="false">
<y:GroupNodeLabelModelParameter.Model>
<y:GroupNodeLabelModel/>
</y:GroupNodeLabelModelParameter.Model>
</y:GroupNodeLabelModelParameter>
</y:Label.LayoutParameter>
<y:Label.Style>
<yjs:DefaultLabelStyle verticalTextAlignment="CENTER" wrapping="CHARACTER_ELLIPSIS" textWrappingShape="LABEL_SHAPE" font="{y:GraphMLReference 8}" textFill="#FFEEEEEE"/>
</y:Label.Style>
</y:Label>
</x:List>
</data>
<data key="d5">
<y:RectD X="190.5" Y="-447.25" Width="150" Height="130"/>
</data>
<data key="d7">
<yjs:GroupNodeStyle tabWidth="30" tabHeight="20" tabInset="3" tabPosition="TOP_TRAILING" groupIcon="MINUS" iconForegroundFill="#FF0B7189" iconOffset="2" minimumContentAreaSize="0,0" hitTransparentContentArea="true" tabBackgroundFill="#FF0B7189" contentAreaFill="#FFFFFFFF" tabFill="#FF9DC6D0" cssClass="y-group-node">
<yjs:GroupNodeStyle.stroke>
<yjs:Stroke fill="#FF0B7189" lineCap="SQUARE" thickness="2"/>
</yjs:GroupNodeStyle.stroke>
</yjs:GroupNodeStyle>
</data>
<graph id="n8:" edgedefault="directed">
<node id="n8::n0">
<data key="d0">10</data>
<data key="d5">
<y:RectD X="229.75" Y="-412.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFA2B4D0"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="155,-453,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n8::n1">
<data key="d0">11</data>
<data key="d5">
<y:RectD X="288" Y="-412.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFA2B4D0"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="200,-453,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n8::n2">
<data key="d0">12</data>
<data key="d5">
<y:RectD X="229.75" Y="-382.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFA2B4D0"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="185,-423,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n8::n3">
<data key="d0">13</data>
<data key="d5">
<y:RectD X="288" Y="-382.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFA2B4D0"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="200,-408,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n8::n4">
<data key="d0">14</data>
<data key="d5">
<y:RectD X="229.75" Y="-352.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFA2B4D0"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="215,-393,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
<port name="p1">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n8::n5">
<data key="d0">15</data>
<data key="d5">
<y:RectD X="288" Y="-352.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFA2B4D0"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="230,-378,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
<port name="p1">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<node id="n8::n6">
<data key="d0">16</data>
<data key="d4">
<x:List>
<y:Label>
<y:Label.Text>n:m</y:Label.Text>
<y:Label.LayoutParameter>
<y:CompositeLabelModelParameter>
<y:CompositeLabelModelParameter.Parameter>
<y:ExteriorLabelModelParameter Position="South" Model="{y:GraphMLReference 7}"/>
</y:CompositeLabelModelParameter.Parameter>
<y:CompositeLabelModelParameter.Model>
<y:CompositeLabelModel>
<y:CompositeLabelModel.LabelModels>
<y:GraphMLReference ResourceKey="7"/>
<y:InteriorLabelModel/>
<x:Static Member="y:FreeNodeLabelModel.Instance"/>
</y:CompositeLabelModel.LabelModels>
</y:CompositeLabelModel>
</y:CompositeLabelModelParameter.Model>
</y:CompositeLabelModelParameter>
</y:Label.LayoutParameter>
<y:Label.Style>
<yjs:DefaultLabelStyle verticalTextAlignment="CENTER" horizontalTextAlignment="CENTER" font="{y:GraphMLReference 8}" textFill="BLACK"/>
</y:Label.Style>
</y:Label>
</x:List>
</data>
<data key="d5">
<y:RectD X="258.875" Y="-352.625" Width="13.25" Height="13.375"/>
</data>
<data key="d7">
<yjs:ShapeNodeStyle stroke="{y:GraphMLReference 6}" fill="#FFB0CCB9"/>
</data>
<data key="d8">
<y:ViewState>
<y:FolderNodeState x:Key="c|view" Layout="245,-363,13.25,13.375"/>
</y:ViewState>
</data>
<port name="p0">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
<port name="p1">
<data key="d18">
<y:ViewState>
<y:Port x:Key="c|view"/>
</y:ViewState>
</data>
</port>
</node>
<edge id="n8::e0" source="n8::n0" target="n8::n1" sourceport="p0" targetport="p0">
<data key="d10"><![CDATA[]]></data>
<data key="d11">
<x:List>
<y:Label LayoutParameter="{y:GraphMLReference 10}" Style="{y:GraphMLReference 11}">
<y:Label.Text>1:1</y:Label.Text>
</y:Label>
</x:List>
</data>
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}">
<yjs:PolylineEdgeStyle.targetArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.targetArrow>
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="n8::e1" source="n8::n2" target="n8::n3" sourceport="p0" targetport="p0">
<data key="d11">
<x:List>
<y:Label LayoutParameter="{y:GraphMLReference 10}" Style="{y:GraphMLReference 11}">
<y:Label.Text>1:n</y:Label.Text>
</y:Label>
</x:List>
</data>
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="n8::e2" source="n8::n6" target="n8::n4" sourceport="p0" targetport="p1">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="n8::e3" source="n8::n6" target="n8::n5" sourceport="p1" targetport="p1">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
</graph>
</node>
<edge id="e0" source="n0" target="n1" sourceport="p1" targetport="p0">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 7}" targetArrow="{y:GraphMLReference 8}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}" cropLength="1"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
<y:GraphMLReference ResourceKey="14"/>
</data>
</edge>
<edge id="e1" source="n0" target="n1" sourceport="p1" targetport="p0">
<edge id="e1" source="n0" target="n4" sourceport="p2" targetport="p0">
<data key="d13">
<y:GraphMLReference ResourceKey="9"/>
<y:GraphMLReference ResourceKey="14"/>
</data>
</edge>
<edge id="e2" source="n0" target="n4" sourceport="p2" targetport="p0">
<edge id="e2" source="n4" target="n5" sourceport="p1" targetport="p0">
<data key="d13">
<y:GraphMLReference ResourceKey="9"/>
</data>
</edge>
<edge id="e3" source="n4" target="n5" sourceport="p1" targetport="p0">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 7}">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}">
<yjs:PolylineEdgeStyle.targetArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}"/>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.targetArrow>
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}"/>
<yjs:Arrow type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}" cropLength="1"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="e4" source="n6" target="n2" sourceport="p1" targetport="p1">
<edge id="e3" source="n6" target="n2" sourceport="p1" targetport="p1">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 7}">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}">
<yjs:PolylineEdgeStyle.targetArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}"/>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.targetArrow>
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}" cropLength="1"/>
<yjs:Arrow type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}" cropLength="1"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="e5" source="n6" target="n1" sourceport="p2" targetport="p1">
<edge id="e4" source="n3" target="n0" sourceport="p0" targetport="p3">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 7}" targetArrow="{y:GraphMLReference 8}">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="TRIANGLE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 6}" cropLength="1"/>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="e5" source="n3" target="n2" sourceport="p1" targetport="p3">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="e6" source="n7" target="n6" sourceport="p0" targetport="p3">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>
</edge>
<edge id="e7" source="n7" target="n1" sourceport="p1" targetport="p2">
<data key="d13">
<yjs:PolylineEdgeStyle stroke="{y:GraphMLReference 12}" targetArrow="{y:GraphMLReference 13}">
<yjs:PolylineEdgeStyle.sourceArrow>
<yjs:Arrow type="NONE" scale="0.75" stroke="#FF663800" fill="{y:GraphMLReference 9}"/>
</yjs:PolylineEdgeStyle.sourceArrow>
</yjs:PolylineEdgeStyle>
</data>

View file

@ -54,18 +54,18 @@ def addpage():
try:
postdict[i]=itype(request.form[i])
except Exception as e:
return "<h2>ERROR: All fields need to be filled and don't play with their names!</h2> Go back and try again."
return errorpage("All fields need to be filled and don't play with their names!")
try:
postdict["size"]=postdict["size"]*int(request.form['size_multiplier'])
except Exception as e:
return "<h2>ERROR: All fields need to be filled and don't play with their names!</h2> Go back and try again."
return errorpage("All fields need to be filled and don't play with their names!")
postdict["owner"]=userdata[0]
res,archid=db.add_archive(postdict)
if res:
return make_response(redirect(f"/view/{str(archid)}"))
else:
return f"<h2>ERROR: {archid}</h2> Go back and try again.", 400
return errorpage(archid), 400
# GET: return normal page
htmlcatlist=get_category_selection(False)
@ -88,7 +88,7 @@ def loginpage():
resp=setcookie("session",sesskey,lifetime)
return resp
else:
return "<h2>You've entered the wrong password. This incident will be reported.</h2><br> Go back and try again."
return errorpage("You've entered the wrong password. This incident will be reported.")
# GET: Login form
else:
return render_template("login.html", title="Login")
@ -99,6 +99,20 @@ def viewpage(archid:int):
archive,category,labels=db.get_archive_info(archid)
return render_template("view.html", title="View Archive",userdata=userdata,login=logged_in,archive=archive,category=category,labels=labels)
@app.route('/delete/<int:archid>', methods=["GET","POST"])
def deletepage(archid:int):
logged_in,userdata=get_login_info(request.cookies.get('session'))
archive,category,labels=db.get_archive_info(archid)
if not logged_in or userdata[0] != archive[8]:
return make_response(redirect(f"/view/{archid}"))
if request.method == 'POST':
if not request.form['archname'] == archive[1]:
return errorpage("The name input doesn't match!")
db.delete_archive(archid)
return make_response(redirect('/'))
# GET: return normal deletion page
return render_template("delete.html", title="Delete Archive",userdata=userdata,login=logged_in,archive=archive)
@app.route('/labels/<int:archid>', methods=["GET","POST"])
def labeleditpage(archid:int):
logged_in,userdata=get_login_info(request.cookies.get('session'))
@ -115,17 +129,15 @@ def labeleditpage(archid:int):
on_labels.append(i)
res, data=db.update_labels(archid, on_labels)
if not res:
return f"<h2>ERROR: {data}</h2>Go back and try again"
return errorpage(data)
return make_response(redirect(f"/view/{archid}"))
# GET: return normal labels page
labels_name_list=[]
for i in labels:
labels_name_list.append(i[0])
return render_template("labels.html", title="Edit Labels",userdata=userdata,login=logged_in,archive=archive,res_labels=label_dict,labels_names=labels_name_list)
@app.route('/search')
def searchpage():
# try to get userdata, else logout state
@ -157,6 +169,9 @@ def searchpage():
## FUNCTIONS
def errorpage(message):
return "<h2>ERROR: " + message + "</h2>Go back and try again"
## Checks if given sesskey is valid and returns user data
## OUTPUT: (if sesskey valid) logged_in:bool=True, userdata:tuple
## (if sesskey invalid) logged_in:bool=False, userdata:tuple=()

View file

@ -31,7 +31,7 @@ class db:
);""")
self.cur.execute("""CREATE TABLE IF NOT EXISTS Users(
ID int PRIMARY KEY AUTO_INCREMENT,
UNAME text NOT NULL,
UNAME text NOT NULL UNIQUE,
DNAME text NOT NULL,
CREATED int NOT NULL,
STATE text,
@ -39,7 +39,7 @@ class db:
);""")
self.cur.execute("""CREATE TABLE IF NOT EXISTS Sessions(
ID int PRIMARY KEY AUTO_INCREMENT,
SESSKEY text NOT NULL,
SESSKEY text NOT NULL UNIQUE,
USERID int NOT NULL,
CREATED int NOT NULL,
LIFE int
@ -124,6 +124,9 @@ class db:
archid=self.cur.fetchone()
return True,archid[0]
def delete_archive(self, archid:int):
self.cur.execute(f"""DELETE FROM Archs WHERE ID={archid}""")
self.cur.execute(f"""DELETE FROM ArchLab WHERE ARCHID={archid}""")
## Returns all relevant information about one (1) archive
## OUTPUT: archive:tuple=(ID:int,NAME:str,HASH:str,SIZE:int,IMPORTED[UNIX]:int,CATEGORY.ID:int,CATEGORY,str,CATEGORY.DESCRIPTION:str,USER.ID:int,DNAME:str),
@ -188,7 +191,7 @@ class db:
## get a list of enabled labels and update the DB to reflect that state
## OUTPUT: (if on_labels empty) bool=False, str
## (else)
def update_labels(self, archid:int, on_labels:list): # TODO: CLEAN!!!!
def update_labels(self, archid:int, on_labels:list):
# fail if no labels passed
if len(on_labels) == 0:
return False, "You have to select at least one label!"

View file

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block meta %}
<link rel="stylesheet" href="/static/view.css" />
{% endblock %}
{% block content %}
<h2>{{archive[1]}}</h2>
<p>Are you sure?</p>
<form action="/delete/{{archive[0]}}" method="post">
<p><b>Enter Archive: </b><input type="text" name="archname" placeholder="Archive Name"></p>
<input type="submit" value="Yes, I am sure! Delete!">
</form>
{% endblock %}

View file

@ -5,7 +5,7 @@
{% endblock %}
{% block content %}
<h2>{{archive[1]}}</h2>
{% if login and userdata[0] == archive[8] %}<a href="/delete/{{archive[0]}}"><button class="big-button"><b>Delete</b></button></a>{% endif %}<h2>{{archive[1]}}</h2>
<div class="grid-container">
<div class="archive-info">
<b>Hash: </b><span>{{archive[2]}}</span>