Unverified Commit f05ce853 authored by CapsLock's avatar CapsLock

[feature] display pictures for domain names on default page

parent e94a918d
......@@ -68,7 +68,6 @@ def orig():
@app.route('/')
@app.route('/', method='POST')
def default(db):
status = ''
if 'status' in request.params:
......@@ -95,8 +94,19 @@ def default(db):
" and name is not null and name <> '' ",
(('%%%s%%' % squery),))
else:
db.execute("select * from domain_names dn"
" where name is not null and name <> '' ")
db.execute("with dns as (select * from domain_names dn)"
" select distinct on (id) * from (select * from dns,"
" (select pic.id picture_id,"
" pic.description,"
" pic.filename picture_filename,"
" pdn.domain_name_id domain_id from pictures pic,"
" pictures_domain_names pdn"
" where pdn.picture_id = pic.id) pp"
" where dns.id = pp.domain_id "
" and name is not null and name <> ''"
" order by random()) ppp;")
# db.execute("select * from domain_names dn"
# " where name is not null and name <> '' ")
domain_names = db.fetchall()
else:
db.execute('with pics as('
......@@ -145,7 +155,7 @@ def autorotate(path):
if not exif:
return False
orientation_key = 274 # cf ExifTags
orientation_key = 274 # cf ExifTags
if orientation_key in exif:
orientation = exif[orientation_key]
......@@ -163,6 +173,7 @@ def autorotate(path):
return False
# upload new pictures
@app.route('/new', method='POST')
def do_upload(db):
......@@ -182,19 +193,19 @@ def do_upload(db):
temp_thumb_folder = os.path.join(temp_folder, 'thumbs')
if (not os.path.exists(dest_folder)
or not os.path.isdir(dest_folder)):
or not os.path.isdir(dest_folder)):
os.makedirs(dest_folder)
if (not os.path.exists(dest_thumb_folder)
or not os.path.isdir(dest_thumb_folder)):
or not os.path.isdir(dest_thumb_folder)):
os.makedirs(dest_thumb_folder)
if (not os.path.exists(temp_folder)
or not os.path.isdir(temp_folder)):
or not os.path.isdir(temp_folder)):
os.makedirs(temp_folder)
if (not os.path.exists(temp_thumb_folder)
or not os.path.isdir(temp_thumb_folder)):
or not os.path.isdir(temp_thumb_folder)):
os.makedirs(temp_thumb_folder)
image_name = '%s%s' % (datetime.datetime.now().strftime('%Y%m%d%H%M%s%f'),
......
......@@ -31,8 +31,11 @@
%tag_closed = False
% end
<div class="large-4 columns">
<div class="panel">
<div class="panel alignCenter">
<p>
<a href="{{ base_url % d['name'] }}">
<img src="uploads/thumbs/{{d['picture_filename']}}" alt="{{d['description']}}"/>
</a>
<a href="{{ base_url % d['name'] }}">{{ '{0}.{1}'.format(d['name'], domain_name) }}</a>
</p>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment