getting ready for another round of development
This commit is contained in:
parent
07a89c8f7a
commit
f571d74f48
@ -6,27 +6,28 @@ import csv
|
||||
import os
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
data_dir = os.path.abspath(os.path.join(script_dir, "../data"))
|
||||
image_dir = os.path.abspath(os.path.join(script_dir, "../static/images"))
|
||||
fieldnames = [
|
||||
'Id',
|
||||
'Publication',
|
||||
'Author',
|
||||
'Year',
|
||||
'Custodian',
|
||||
'Fields',
|
||||
'Type',
|
||||
'Publishers',
|
||||
'License',
|
||||
'LicenseShort',
|
||||
'Highlights',
|
||||
'Comments',
|
||||
'Currently borrowed by',
|
||||
"Id",
|
||||
"Publication",
|
||||
"Author",
|
||||
"Year",
|
||||
"Custodian",
|
||||
"Fields",
|
||||
"Type",
|
||||
"Publishers",
|
||||
"License",
|
||||
"LicenseShort",
|
||||
"Highlights",
|
||||
"Comments",
|
||||
"Currently borrowed by",
|
||||
]
|
||||
|
||||
|
||||
def parsecsv():
|
||||
"""Test function to inspect csv file as dict"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
return csv_as_dict
|
||||
@ -34,7 +35,7 @@ def parsecsv():
|
||||
|
||||
def getpublications():
|
||||
"""get an overview of all publications for the main page"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
publications = {}
|
||||
@ -49,7 +50,7 @@ def getpublications():
|
||||
"Type": row["Type"].lower().title(),
|
||||
"Year": year,
|
||||
"License": row["LicenseShort"].lower().title(),
|
||||
"Image": hasimage(row["Id"])
|
||||
"Image": hasimage(row["Id"]),
|
||||
}
|
||||
publications[row["Id"]] = pubinfo
|
||||
return publications
|
||||
@ -66,7 +67,7 @@ def hasimage(id):
|
||||
|
||||
def gettypes():
|
||||
"""for the dynamic menu get the unique types of publicatons"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
listoftypes = []
|
||||
@ -79,7 +80,7 @@ def gettypes():
|
||||
|
||||
def getyears():
|
||||
"""for the dynamic menu get the unique years for publicatons"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
listofyears = []
|
||||
@ -95,7 +96,7 @@ def getyears():
|
||||
|
||||
def getlicenses():
|
||||
"""for the dynamic menu get the unique liscenses for publicatons"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
listoflicenses = []
|
||||
@ -110,12 +111,12 @@ def getlicenses():
|
||||
|
||||
def getfieldsofinterest():
|
||||
"""for the R&R page get the fields of interest from the publicatons"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
fieldsofinterest = {}
|
||||
for row in csv_as_dict:
|
||||
fields = row["Fields"].split(',')
|
||||
fields = row["Fields"].split(",")
|
||||
fieldsofinterest[row["Id"]] = fields
|
||||
return fieldsofinterest
|
||||
|
||||
@ -146,14 +147,14 @@ def getpublicationfromcsvrow(row):
|
||||
"Highlights": row["Highlights"],
|
||||
"Comments": row["Comments"],
|
||||
"Borrowed": borrowed,
|
||||
"Image": hasimage(row["Id"])
|
||||
"Image": hasimage(row["Id"]),
|
||||
}
|
||||
return pubinfo
|
||||
|
||||
|
||||
def getfullpublication(pubid):
|
||||
"""For the single book view, most complete overview"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
pubinfo = {}
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
@ -167,7 +168,7 @@ def getfullpublication(pubid):
|
||||
|
||||
def generatenewpublicationid():
|
||||
"""When uploading a book generate a new unique ID"""
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
libcsv = open(os.path.join(data_dir, "varlib.csv"), "r")
|
||||
allidsincsv = []
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
@ -180,9 +181,8 @@ def writepublication(uploadform):
|
||||
"""When uploading a publication writes entry to the csv"""
|
||||
id = generatenewpublicationid()
|
||||
with open(
|
||||
os.path.join(script_dir, "varlib.csv"),
|
||||
'a',
|
||||
newline='') as csvfile:
|
||||
os.path.join(data_dir, "varlib.csv"), "a", newline=""
|
||||
) as csvfile:
|
||||
csv_as_writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
||||
csv_as_writer.writerow(
|
||||
{
|
||||
@ -199,16 +199,17 @@ def writepublication(uploadform):
|
||||
"Highlights": uploadform.highlights.data,
|
||||
"Comments": uploadform.comments.data,
|
||||
"Currently borrowed by": uploadform.borrowed.data,
|
||||
})
|
||||
}
|
||||
)
|
||||
print("succesfully written book to csv")
|
||||
return id
|
||||
|
||||
|
||||
def editborrowedby(pubid, borrower):
|
||||
"""Edits the borrowed by field for a publication entry in csv"""
|
||||
tempfile = NamedTemporaryFile('w+t', newline='', delete=False)
|
||||
filename = os.path.join(script_dir, "varlib.csv")
|
||||
with open(filename, 'r', newline='') as libcsv, tempfile:
|
||||
tempfile = NamedTemporaryFile("w+t", newline="", delete=False)
|
||||
filename = os.path.join(data_dir, "varlib.csv")
|
||||
with open(filename, "r", newline="") as libcsv, tempfile:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
csv_as_writer = csv.DictWriter(tempfile, fieldnames=fieldnames)
|
||||
# use the reader to read where, then writer to write the new row.
|
||||
|
@ -1,57 +0,0 @@
|
||||
Id,Publication,Author,Year,Custodian,Fields,Type,Publishers,License,LicenseShort,Highlights,Comments,Currently borrowed by
|
||||
1,The Economics of Anarchism,Anarcho,2012,Varia,"Economics, Anarchism",Zine,theanarchistlibrary.org,Anti-copyright,Anti-copyright,"The labourer retains, even after he has recieved his wages, a natural right in the thing he has produced",,No one
|
||||
2,Identity Politics - An Anthology,The Anarchist Library,,Varia,Identity politics,Zine,Paper Jam Collective,No license mentioned,No license mentioned,,Varia,No one
|
||||
3,The mythology of work,CrimeThinc.com,,Varia,"Work, Anticapitalism",Zine,CrimeThinc.com,No license mentioned,No license mentioned,,"A selection from 'Work', a 376-page analysis of contemporary capitalism",
|
||||
4,Forget Shorter Showers - Why Personal Change Does Not Equal Political Change,Derrick Jensen,2009,Varia,Environmental justice,Zine,,No license mentioned,No license mentioned,Green consumerism isn't enough.,,
|
||||
5,Choreo-Graphic-Hypothesis,"<meta-author=""Joana Chicau"";>",2018,Varia,"Live Coding, Choreography",Paperback,Self published: Joana Chicau,Free Art License 1.3,Free Art License,"Theatrical actions are not necessary to the performance, Avoid if at all possible",,
|
||||
6,Point of no Return,,2013,Varia,Anarchism in the West,Zine,,No license mentioned,No license mentioned,,Stories about becoming an anarchist in the West in the 80s,
|
||||
7,Waar slapen de kroegtijgers van Oud Charlois,Jacco Weener,,Varia,"Oud Charlois, Drawing",Paperback,Self-published,No license mentioned,No license mentioned,,,
|
||||
8,Dubbeldruk Play with me,"Editorial team: Karin de Jong, Giulia de Giovanelli, Floor van Luijk",2019,Varia,"Copyright, Publishing, Printing",Parazine,Printroom,Free art license,Free art license,,"Confusing licenses mentioned in the about text on the back of the publication, FAL, Copy-left and copy right all mentioned",
|
||||
9,To Boldly Go: a starters guide to hand made and diy films,Film Werkplaats Worm Rotterdam,2008,Varia,"Experimental film, Analog film, DIY, Hand-made",Paperback,Knust (Nijmegen),'No license mentioned,No license mentioned,,,
|
||||
10,Anarchism: Basic concepts and ideas,Peter Storm,2018,Varia,"Anarchism, Dutch Theory",Zine,Ravotr Editions in collaboration with Paper Jam,Feel free to use and copy this text as you see fit. Mentioning source and author would be greatly appreciated.,No license mentioned,,Revised text of a transcribed lecture Storm gave in Rotterdam.,
|
||||
11,Queering Anarchism,"Deric Shannon, Abbey Willis",,Varia,"Anarchism, Queer Theory",Zine,Paper Jam Collective,No license mentioned,No license mentioned,,,
|
||||
12,Abolish restaurants,Prole.info,2010,Varia,"Labour, Food industry",Paperback,Pm Press,Copyright 2010,Copyright,Drawing on a range of anti-capitalist ideas as well as a heaping plate of personal experience,,CCL
|
||||
13,"Elk Woord Een Vonk: Verboden Teksten, verwerpelijke vervolging: de zaak Joke Kaviaar",Steungroep 13 September,2014,Varia (or Luke?),"Joke Kaviaar, Immigration, Activism, Forbidden Texts, Incarceration",Softcover,Self-published,Copyleft,Copyleft,,https://13-september.nl,
|
||||
14,A NO BORDERS manifesto,Ill Will Editions,2015,Varia,Migrant justice,Zine,Self-published,No license mentioned,No license mentioned,,,
|
||||
16,Futur Musique,De fanfare voor vooruit strevende volksmuziek,2018,Varia,"Musical Instruments, DIY",Zine,Self-published,No license mentioned,No license mentioned,Copied instructions on building one's own musical instruments,,
|
||||
17,Franchir le cap,Quentin Juhel,2019,Varia,Convivial computation,Zine,Self-publsihed,Creative commons CC-BY-SA,Creative commons,,,
|
||||
18,Consensus: Decision Making,Seeds For Change UK,2010,Varia,"Decision making, Consensus",Zine,Self-published,No license mentioned,No license mentioned,Short guide ,,
|
||||
19,"Waar ook op gestemd wordt, wij laten ons niet regeren",Anarchistische Groep Nijmegen,2014,Varia,Democracy,Zine,Self-published,No license mentioned,No license mentioned,,,
|
||||
20,The NGO sector: the trojan horse of capitalism,Crn Blok,,Varia,"Anti-capitalism, NGO",Zine,Self-published,Copyleft,Copyleft,,,
|
||||
21,Messing Around With Packet Radio,"Roel Roscam Abbing, Dennis De Bel",,Varia,"Packet radio, DIY, radio, wireless",Zine,Self-published,Public domain,Public domain,,,
|
||||
22,Organising Socially: affinity groups & decision making,Seeds for change,,Varia,"Consensus, Decision making, Affinity groups",Zine,Paper Jam Collective,No license mentioned,No license mentioned,,,
|
||||
23,The Moral of the Xerox,"Florian Cramer, Clara Lobregat Balaguer",2017,Varia,"Piracy, Cultural Appropriation",Zine,Self-published,No license mentioned,No license mentioned,"Printed in diocese of Cologne, Germany on the joyous occasion of the Pluriversale VII: Stealing from the west for the critical parishioners of Akademie der Kunste der Welt",,
|
||||
24,Non-Western Anarchisms,Jason Adams,,Varia,Non-Western Anarchisms,Zine,Zaba Books,No license mentioned,No license mentioned,"The purpose of this paper is to help anarchist/anti-authoritarian movements active today to reconceptualise the history and theory of first-wave anarchism on the global level, and to reconsider its relevance to the continuing anarchist project.",,
|
||||
33,The immaterial labor union #7: immersive advertisement,Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια,,Varia,"labour, Advertisement, immersion, social media",Zine,Self-published,Zine is published under Gnu free documentation license 1.3 unless otherwise specified ,GNU Free Documentation License,,,
|
||||
34,The immateriality labor union #10: immateriality,Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια,2017,Varia,"Labour, Immateriality",Zine,Self-published,GNU Free Documentation License,GNU Free Documentation License,,Varia,No one
|
||||
35,The immaterial labor union. Special Issue #1: Homebrew Server Club,Homebrew Server Club,2017,Varia,"Self-Hosting, Servers, DIY",Zine,Self-published,CC-BY-SA,Creative commons,,,
|
||||
36,Pervasive labour union. Special issue #2: The Entreprecariat,Silvio Lorusso,2017,Varia,"Entreprecariat, Labour, Precarity",Zine,Self-published,No license mentioned,No license mentioned,,Between April and May 2017 the Zine's name changed from Immaterial Labor Union to Pervasive Labour Union,
|
||||
37,'Pervasive labour union #13: Fed Up,Lídia Pereira,2019,Varia,"Labour, DIY, federation",Zine,Self-published,"GNU Free Documentation License 1.3, CC-0, Copyright (C) 2019, Julia Janssen, Peer Production License",GNU Free Documentation License,,,
|
||||
38,Each Page a Function,Raphaël Bastide,2019,Varia,"Automation, Drawing, Web to Print",Paperback,LeMegot editions,No license mentioned,No license mentioned,,,
|
||||
39,In Beweging: Magazine van de Anarchistische Groep Nijmegen,Anarchistische Groep Nijmegen ,2018,Varia,"Anarchism, 1st of May, Nijmegen",Zine,Self-published,No license mentioned,No license mentioned,,Anarchistische Bieb de Zwarte Uil. library in Nijmegen open on saturday from 12:00 till 17:30,
|
||||
40,Deep pockets #2 Shadowbook: Writing through the digital 2014-2018,Miriam Rasch,2018,Varia,"Language, digital, communication",Paperback,Institute of Network Cultures,CC BY-NC-SA 4.0,Creative Commons,,,
|
||||
41,The Techno Galactic Software Observatory Reader,Constant,2018,Varia,"Software Studies, Software Curious People, Observation",Paperback,Self- published,No license mentioned,No license mentioned,,Reader for Techno Galactic Software Observatory work session,
|
||||
42,Upsetting Settings,Piet Zwart Institute,2019,Varia,"Catalogue, Experimental publishing",Softcover,XPUB,Copyleft,Copyleft,,Dissertations from the Piet Zwart Institute 2017-2019,
|
||||
43,I Have Witnessed First Time Experiences ,Connie Butler,2016,Varia,Fine Art,Softcover,Piet Zwart institute MFA,Copyright 2016,Copyright,,,
|
||||
44,The Age of Aquariums: old horoscopes for the new year,Brenda Bosma,2013,Varia,Horoscope,Paperback,Subbacultcha!,No license mentioned,No license mentioned,,,
|
||||
45,The Internet Measurement Handbook,,2018,Varia,"Internet, blackout, cyber-security",Paperback,Netblocks,CC,Creative Commons,,,
|
||||
46,Issue #4 2019,Design Department Sandberg,2019,Varia ,Design theory,Paperback,Drukkerij RaddraaierSSP,No license mentioned,No license mentioned,,Dissertations from the Design Museum,
|
||||
47,O Bike and Friends,Dennis De Bel,,Varia,"Bike sharing, DIY",Zine,Self-published,No license mentioned,No license mentioned,,,
|
||||
48,Algoliterary Encounters,Algolit,2017,Varia,"Natural text processing, machine learning, algorithms",Catalogue,Algolit,Free Art License,Free Art License,,,
|
||||
49,Der Fall von Afrin,Unknown,,Varia,Turkish politics,Zine,Unknown,No license mentioned,No license mentioned,,,
|
||||
50,Andy de Fiets: Letter to Robin Kinross ,"Paul Haworth, Sam de Groot",2010,Varia,Typography,Paperback,TRUE TRUE TRUE Amsterdam,"Copyright 2009,2010",Copyright,,,
|
||||
51,Ora Elastică,ODD,2018,Varia,"Art, Indonesia, Romania, non-western art theory",Softcover,frACTalia,No license mentioned,No license mentioned,,,
|
||||
52,4 x Through The Labyrinth,"O. Nicolai & J. Wenzel, translated by Sadie Plant",2012,Joana Chicau,Labyrinths,Softcover,Rollo Press,Copyright,Copyright,,,
|
||||
53,Towards an Immersive Intelligence,Joseph Nechvatal,2009,Joana Chicau?,"Virtual reality, Computer Art",Paperback,Edgewise,Copyright,Copyright,,,
|
||||
54,Xavan et Jaluka - The Death of the Authors 1946,Peter Westenberg,2018,Varia,Public domain,Zine,Constant Verlag,Copyleft,Copyleft,,,
|
||||
55,Spreekt U Sint-Gillis? Parlez-vous Saint-Gillois?,,,Varia,"Bruxelles, Language, Sint-Gillis",Softcover,Constant Verlag,Copyleft,Copyleft,,,
|
||||
56,Mondothèque: a radiated book,"André Castro , Sînziana Păltineanu , Dennis Pohl , Dick Reckard , Natacha Roussel , Femke Snelting , Alexia de Visscher",2016,Varia,"Archive, Otlet, Library science, Mondaneum, Google, Mons",Softcover,Constant,Copyleft,Copyleft,,,
|
||||
57,"The Death of the Authors: 'James Joyce, Rabindranath Tagore & Their Return to Life in Four Seasons",A Constant Remix,2013,Varia,"James Joyce, Ulysses",Softcover,Constant,Public domain,Public domain,,'generated from Public domain sources,
|
||||
58,Verbindingen/Jonctions 10 : Tracks in electr(on)ic fields,Constant,2009,Varia,"Art, activism, technological culture",Softcover,Constant,Copyleft,Copyleft,,,
|
||||
59,Conversations,Constant,2014,Varia,"Software studies, Libre graphics",Softcover,Constant Verlag,Copyleft,Copyleft,,,
|
||||
60,Networks of one's own #1: Etherbox,"Michael Murtaugh, An Mertens, Roel Roscam Abbing, Femke Snelting",2018,Varia,"Networks, Digital Infrastructures, DIY, DIWO, Executable publication, Experimental Publishing, wireless",Paperback,Constant Verlag,Copyleft,Copyleft,,,
|
||||
61,Mots de la cage aux ours - woorden uit de berenkuil,Constant,2012,Varia,"words, language, Bruxelles",Softcover,Constant,Copyleft,Copyleft,,,
|
||||
62,Snake rituals and switching circuits,Florian Cramer,2009,Danny,"mass communication, personal communication, new media",paperback,Piet Zwart Institute,Creative Commons Attribution-Share Alike 3.0,Creative Commons,The function of a medium is ultimately decided by its users and not by its creators,,
|
||||
63,Magium issue 1: On Eating in isolation,Alice Strete,2020,Varia,"food, sharing, personal stories, consumption",zine,Self Published,Free Art License,Free Art License,,,No one
|
||||
64,Networks of One's Own 2: three takes on taking care,"Varia, Constant and Colm O’Neill",2019,Varia,"Software, internet, taking care, homebrew",paperback,Varia,Copyleft,Copyleft,Networks Of One’s Own is a periodic para-nodal publication that is itself collectively within a network.,,No one
|
||||
65,My Hard-Drive Died Along With My Heart ,Thomas Walsklaar,2016,Varia,"Hard-drives, Data, Loss, Trust, Technology, collection, materiality, obsolescence, preservation, progress, writing ",paperback,Self Published, No License Mentioned,No License Mentioned,,"We always seem to be looking for a new technical solution for knowledge and information storage. We hope there is one magical, final solution, one that will solve every issu But easy solutions create their own problems. The perceived view of the stable nature of digital information differs from reality. There are many points of failure, like old physical formats, lost or non functional machines, companies that go bankrupt, file formats with no support in the future, or changing user licenses. It seems that the more technical the technology gets, the more problems it creates.",No one
|
|
3
library/data/.gitignore
vendored
Normal file
3
library/data/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*
|
||||
*/
|
||||
!.gitignore
|
@ -31,8 +31,8 @@ from csvparser.csvparser import (
|
||||
|
||||
csrf = CSRFProtect()
|
||||
APP = flask.Flask(__name__, static_folder="static")
|
||||
APP.config['SECRET_KEY'] = 'ty4425hk54a21eee5719b9s9df7sdfklx'
|
||||
APP.config['UPLOAD_FOLDER'] = 'tmpupload'
|
||||
APP.config["SECRET_KEY"] = "ty4425hk54a21eee5719b9s9df7sdfklx"
|
||||
APP.config["UPLOAD_FOLDER"] = "tmpupload"
|
||||
csrf.init_app(APP)
|
||||
|
||||
|
||||
@ -57,9 +57,10 @@ def index():
|
||||
def upload():
|
||||
"""Upload route, a page to upload a book to the csv"""
|
||||
uploadform = PublicationForm()
|
||||
if request.method == 'POST':
|
||||
if (uploadform.validate_on_submit() and
|
||||
checksecret(uploadform.secret.data)):
|
||||
if request.method == "POST":
|
||||
if uploadform.validate_on_submit() and checksecret(
|
||||
uploadform.secret.data
|
||||
):
|
||||
id = writepublication(uploadform)
|
||||
saveimage(uploadform.image.data, id)
|
||||
return redirect(str(id), code=303)
|
||||
@ -74,24 +75,25 @@ def show_book(publicationID):
|
||||
"""route for a single publication, shows full info and allows borrowing"""
|
||||
fullpublication = getfullpublication(publicationID)
|
||||
borrowform = BorrowForm()
|
||||
if request.method == 'POST':
|
||||
if (borrowform.validate_on_submit() and
|
||||
checksecret(borrowform.secret.data)):
|
||||
if request.method == "POST":
|
||||
if borrowform.validate_on_submit() and checksecret(
|
||||
borrowform.secret.data
|
||||
):
|
||||
editborrowedby(publicationID, borrowform.borrowed.data)
|
||||
fullpublication["Borrowed"] = borrowform.borrowed.data
|
||||
return render_template(
|
||||
"publication.html",
|
||||
fullpublication=fullpublication,
|
||||
publicationID=publicationID,
|
||||
borrowform=borrowform
|
||||
)
|
||||
# return a full publication with or without form errors
|
||||
return render_template(
|
||||
"publication.html",
|
||||
fullpublication=fullpublication,
|
||||
publicationID=publicationID,
|
||||
borrowform=borrowform
|
||||
)
|
||||
borrowform=borrowform,
|
||||
)
|
||||
# return a full publication with or without form errors
|
||||
return render_template(
|
||||
"publication.html",
|
||||
fullpublication=fullpublication,
|
||||
publicationID=publicationID,
|
||||
borrowform=borrowform,
|
||||
)
|
||||
|
||||
|
||||
@APP.route("/pastevents")
|
||||
@ -115,10 +117,10 @@ def upcoming_or_latest():
|
||||
ics = get("https://varia.zone/events.ics").text
|
||||
gcal = Calendar.from_ical(ics)
|
||||
eventtimes = [
|
||||
c.get("dtstart").dt for c in gcal.walk()
|
||||
if c.name == "VEVENT"
|
||||
and "Read & Repair" in c.get("summary")
|
||||
]
|
||||
c.get("dtstart").dt
|
||||
for c in gcal.walk()
|
||||
if c.name == "VEVENT" and "Read & Repair" in c.get("summary")
|
||||
]
|
||||
now = datetime.datetime.now()
|
||||
eventtimes.sort()
|
||||
eventtimes.reverse()
|
||||
@ -130,16 +132,16 @@ def upcoming_or_latest():
|
||||
|
||||
def saveimage(image, id):
|
||||
"""helper function that can save images"""
|
||||
image.save(os.path.join(APP.config['UPLOAD_FOLDER'], image.filename))
|
||||
image.save(os.path.join(APP.config["UPLOAD_FOLDER"], image.filename))
|
||||
orig_image = Image.open(
|
||||
os.path.join(APP.config['UPLOAD_FOLDER'] ,image.filename)
|
||||
)
|
||||
os.path.join(APP.config["UPLOAD_FOLDER"], image.filename)
|
||||
)
|
||||
new_width = 640
|
||||
new_height = int(new_width * orig_image.height / orig_image.width)
|
||||
resized_image = orig_image.resize((new_width, new_height), Image.ANTIALIAS)
|
||||
filename = secure_filename("image-{0}.jpg".format(id))
|
||||
resized_image.save(os.path.join("static/images/", filename), "JPEG")
|
||||
os.remove(os.path.join(APP.config['UPLOAD_FOLDER'], image.filename))
|
||||
os.remove(os.path.join(APP.config["UPLOAD_FOLDER"], image.filename))
|
||||
|
||||
|
||||
def checksecret(secret):
|
||||
|
3
library/static/images/.gitignore
vendored
Normal file
3
library/static/images/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*
|
||||
*/
|
||||
!.gitignore
|
@ -5,7 +5,6 @@ from wtforms import validators
|
||||
from wtforms import (
|
||||
StringField,
|
||||
IntegerField,
|
||||
TextField,
|
||||
RadioField,
|
||||
SubmitField,
|
||||
)
|
||||
@ -75,19 +74,18 @@ class PublicationForm(FlaskForm):
|
||||
),
|
||||
],
|
||||
)
|
||||
highlights = TextField("Highlights from the publication:")
|
||||
comments = TextField("Comments on the publication:")
|
||||
highlights = StringField("Highlights from the publication:")
|
||||
comments = StringField("Comments on the publication:")
|
||||
borrowed = StringField("Currently borrowed by:")
|
||||
image = FileField('Image of the book:', validators=[
|
||||
FileAllowed(['jpg', 'png', 'gif'], 'Images only!')
|
||||
])
|
||||
image = FileField(
|
||||
"Image of the book:",
|
||||
validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")],
|
||||
)
|
||||
secret = StringField(
|
||||
"Librarians secret:",
|
||||
[
|
||||
validators.InputRequired(),
|
||||
Length(
|
||||
min=2, message="Fill in the secret to unlock to library."
|
||||
),
|
||||
Length(min=2, message="Fill in the secret to unlock to library."),
|
||||
],
|
||||
)
|
||||
submit = SubmitField("Submit")
|
||||
|
Loading…
Reference in New Issue
Block a user