Compare commits

...

3 Commits

Author SHA1 Message Date
Kostanjevec e1295a3840 renderanje pdfjev z pdfobject deluje 2022-06-03 19:13:23 +02:00
Kostanjevec 418d8b2b70 nova nc knjiznica za pridobivanje public link in sprememba db da vsebuje te linke 2022-06-03 19:12:14 +02:00
Kostanjevec 47236128f6 nova nc knjižnica za pridobivanje urljev 2022-06-03 19:11:11 +02:00
7 changed files with 84 additions and 8 deletions

12
app.py
View File

@ -12,6 +12,9 @@ from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from config import CONFIG
from get_public_links import test_file
engine = create_engine(CONFIG['DB_CONNECTION'])
dbsessionmaker = sessionmaker(bind=engine)
dbsession = dbsessionmaker()
@ -56,7 +59,11 @@ def create_app(test_config=None):
d = get_deck(user_id)
deck_index+=1
card = d[deck_index]
if deck_index < len(d):
card = d[deck_index]
else:
deck_index =-1
return end_of_session()
#for card in d: #TODO to ne dela, nevem kako renderat zapooredno kartic
if request.method == 'POST':
@ -86,6 +93,9 @@ def create_app(test_config=None):
session.pop("user_id", None)
return index()
@app.route('/end')
def end_of_session():
return "end"
#app.register_blueprint(bp) # ??
app.register_blueprint(auth_bp)

View File

@ -32,9 +32,9 @@ class Card(Base):
title = Column(String(1024))
owner_id = Column(Integer, ForeignKey("user.id"), nullable=False)
interest_rate = Column(Float)
item_location = Column(String(1024))
# shared = Column(Bool)
# item_location = Column(String)
# item_type = Column(String)
# content_type = Column(String)
# item_size = Column(Integer)

View File

@ -12,9 +12,16 @@ options = {
}
client = Client(options)
print(dir(client))
def get_file_list():
return client.list("/GIA CLOUD")
# for file in get_file_list():
# print(file)
for file in get_file_list():
link = client.get_url(file)
print(link)
info = client.info("/GIA CLOUD")

View File

@ -0,0 +1,30 @@
import nextcloud_client
nc = nextcloud_client.Client('https://obzorje.kompot.si')
nc.login('gia', 'gia0000!')
# nc.put_file('testdir/remotefile.txt', 'localfile.txt')
seznam = nc.list("/GIA CLOUD")
name = seznam[0].get_name()
public_share = nc.share_file_with_link("/GIA CLOUD/"+name)
public_link= public_share.get_link()+"/download/"+name
print(public_link)
def test_file():
return public_link
"""""
options = {
#'webdav_login': 'gia',
#'webdav_password': 'gia0000!',
'webdav_token': '2WmQL-G7Jbg-6t7sN-JBRSe-eBGy5',
'webdav_hostname': 'https://obzorje.kompot.si/remote.php/dav/files/dab82616-284e-103c-9287-6de9b1978576/'
#'webdav_hostname': 'https://obzorje.kompot.si',
#'webdav_root': '/remote.php/dav/files/'
}"""

View File

@ -5,16 +5,29 @@ from create_db import Card
from get_files import get_file_list
from config import CONFIG
import nextcloud_client
engine = create_engine(CONFIG['DB_CONNECTION'])
dbsessionmaker = sessionmaker(bind=engine)
dbsession = dbsessionmaker()
stuff = get_file_list()
for item in stuff:
if item[-4:] == ".pdf":
card = Card(title=item, interest_rate=-1.0, owner_id=1)
nc = nextcloud_client.Client('https://obzorje.kompot.si')
nc.login('gia', 'gia0000!')
l = nc.list("/GIA CLOUD")
#stuff = get_file_list()
for item in l:
if item.get_name()[-4:] == ".pdf":
name = item.get_name()
public_share = nc.share_file_with_link("/GIA CLOUD/"+name)
public_link = public_share.get_link()+"/download/"+name
card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=public_link)
dbsession.add(card)
dbsession.commit()

View File

@ -131,4 +131,8 @@ html {
input[type=submit] {
align-self: start;
min-width: 10em;
}
#pdf-doc {
height: calc(100vh - 332px);
}

View File

@ -12,6 +12,11 @@
<header>
<h1>{{ card['title'] }}</h1>
</header>
<!--iframe src={{ card['item_location'] }} width="auto" height="auto"> </iframe-->
<div id="pdf-doc"></div>
<form method="post">
<button input type="submit" name="rate" data-cardtitle=card[title] value="Yes">Yes</button>
<button input type="submit" name="rate" value="Maybe">Maybe</button>
@ -19,4 +24,11 @@
</form>
</div>
</article>
<script type="text/javascript" src="{{ url_for('static', filename='js/pdfobject.min.js') }}"></script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function (){
PDFObject.embed("{{ card['item_location'] }}", "#pdf-doc");
});
</script>
{% endblock %}