Esempio n. 1
0
def update_gallery_images():
    galleries = Gallery.get_galleries(published=False)
    for gallery in galleries:
        for item in gallery.get('items', []):
            if item.get('image_name'):
                print("{}    {}".format(gallery.get('uuid'),
                                        item.get('image_name')))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    item.get('image_name'))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    "{}_thumbnail".format(item.get('image_name')))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    "{}_small".format(item.get('image_name')))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    "{}_medium".format(item.get('image_name')))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    "{}_large".format(item.get('image_name')))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    "{}_grande".format(item.get('image_name')))
                update_image_headers(
                    'galleries/{}'.format(gallery.get('uuid')),
                    "{}_jumbo".format(item.get('image_name')))
Esempio n. 2
0
def get_galleries():
    galleries = Gallery.get_galleries(published=False)
    if request.is_xhr:
        return json.dumps(galleries), 200, {'Content-Type': 'application/json'}
    g.nav_view = 'galleries'
    galleries = [json.dumps(gallery) for gallery in galleries]
    return render_template('admin/galleries.html', galleries=galleries)
Esempio n. 3
0
def blog_feed():
    posts = Gallery.get_list(published=True, to_json=True)

    feed_url = "{}/blog/feed.atom".format(g.app_base_link)
    feed = AtomFeed('KateHeddleston.com Blog Posts',
                    feed_url=feed_url,
                    url='{}/blog'.format(g.app_base_link))

    for post in posts:
        post_html = []
        for item in post.get('items'):
            item_text = ""
            if item.get('title'):
                item_text += u'<h2>{}</h2><br>'.format(item.get('title'))
            if item.get('image_name'):
                img_src = u'{}/{}'.format(post.get('base_url'), item.get('image_name'))
                item_text += u"<img src='{}' />".format(img_src)
            if item.get('image_caption'):
                item_text += u"<div>{}</div>".format(item.get('image_caption'))
            item_text += '<br>'
            item_text += item.get('body')
            post_html.append(item_text)
        text = '</p><p>'.join(post_html)
        text = '<p>' + text + '</p>'

        post_url = "{}/blog/{}".format(g.app_base_link, post.get('uuid'))
        published_at = datetime.datetime.strptime(post['published_at_raw'], '%Y-%m-%dT%H:%M:%S')
        feed.add(post.get('name'),
                 unicode(text),
                 content_type='html',
                 author=post.get('author'),
                 url=post_url,
                 updated=published_at,
                 published=published_at)
    return feed.get_response()
Esempio n. 4
0
def about():
    g.nav_view = 'about'
    gallery = Gallery.get(uuid='7baf4d66-afa2-46dd-8fee-8b113d255d14')
    return render_template('about.html',
                           gallery=gallery.to_dict(),
                           gallery_items=[item.to_dict() for item in gallery.items()],
                           gallery_uuid='7baf4d66-afa2-46dd-8fee-8b113d255d14')
Esempio n. 5
0
def blog_feed():
    posts = Gallery.get_list(published=True, to_json=True)

    feed_url = "{}/blog/feed.atom".format(g.app_base_link)
    feed = AtomFeed('KateHeddleston.com Blog Posts',
                    feed_url=feed_url,
                    url='{}/blog'.format(g.app_base_link))

    for post in posts:
        post_html = []
        for item in post.get('items'):
            item_text = ""
            if item.get('title'):
                item_text += u'<h2>{}</h2><br>'.format(item.get('title'))
            if item.get('image_name'):
                img_src = u'{}/{}'.format(post.get('base_url'), item.get('image_name'))
                item_text += u"<img src='{}' />".format(img_src)
            if item.get('image_caption'):
                item_text += u"<div>{}</div>".format(item.get('image_caption'))
            item_text += '<br>'
            item_text += item.get('body')
            post_html.append(item_text)
        text = '</p><p>'.join(post_html)
        text = '<p>' + text + '</p>'

        post_url = "{}/blog/{}".format(g.app_base_link, post.get('uuid'))
        published_at = datetime.datetime.strptime(post['published_at_raw'], '%Y-%m-%dT%H:%M:%S')
        feed.add(post.get('name'),
                 text,
                 content_type='html',
                 author=post.get('author'),
                 url=post_url,
                 updated=published_at,
                 published=published_at)
    return feed.get_response()
Esempio n. 6
0
def about():
    g.nav_view = 'about'
    gallery = Gallery.get(uuid='7baf4d66-afa2-46dd-8fee-8b113d255d14')
    return render_template('about.html',
                           gallery=gallery.to_dict(),
                           gallery_items=[item.to_dict() for item in gallery.items()],
                           gallery_uuid='7baf4d66-afa2-46dd-8fee-8b113d255d14')
Esempio n. 7
0
def create_gallery():
    data = json.loads(request.data)
    try:
        gallery = Gallery.create_gallery(**data)
    except ValueError as e:
        flash(e.message, 'danger')
        return json.dumps({'message': e.message}), 400, {'Content-Type': 'application/json'}
    return json.dumps(gallery), 200, {'Content-Type': 'application/json'}
Esempio n. 8
0
def blog_post_title(blog_attr):
    gallery = Gallery.get_custom_url(blog_attr)

    if gallery is None:
        gallery = Gallery.get(uuid=blog_attr)
        if gallery is None:
            abort(404)
    latest_title_url = gallery.latest_url_title()
    if blog_attr != latest_title_url:
        return redirect(u'{}/blog/{}'.format(config.APP_BASE_LINK, latest_title_url))
    current_url = u"{}/blog/{}".format(config.APP_BASE_LINK, blog_attr)
    return render_template('post.html',
                           gallery_uuid=gallery.uuid,
                           gallery=gallery.to_dict(),
                           current_url=current_url,
                           facebook_app_id=config.FACEBOOK_APP_ID,
                           full_page=True)
Esempio n. 9
0
def get_comments_for_galleries():
    galleries = Gallery.get_list(published=True)
    tweets = []
    for gallery in galleries:
        gallery_uuid = gallery.uuid
        url = 'https://www.kateheddleston.com/blog/{}'.format(gallery_uuid)
        update_facebook_comments(url, gallery_uuid)
        tweets = tweets + update_tweet_comments(url, gallery_uuid)
    return tweets
Esempio n. 10
0
def blog_post_title(blog_attr):
    gallery = Gallery.get_custom_url(blog_attr)

    if gallery is None:
        gallery = Gallery.get(uuid=blog_attr)
        if gallery is None:
            abort(404)
    latest_title_url = gallery.latest_url_title()
    if blog_attr != latest_title_url:
        return redirect(u'{}/blog/{}'.format(config.APP_BASE_LINK, latest_title_url))
    current_url = u"{}/blog/{}".format(config.APP_BASE_LINK, blog_attr)
    return render_template('post.html',
                           gallery_uuid=gallery.uuid,
                           gallery=gallery.to_dict(),
                           gallery_items=[item.to_dict() for item in gallery.items()],
                           current_url=current_url,
                           facebook_app_id=config.FACEBOOK_APP_ID,
                           full_page=True)
Esempio n. 11
0
def get_comments_for_galleries():
    galleries = Gallery.get_list(published=True)
    tweets = []
    for gallery in galleries:
        gallery_uuid = gallery.uuid
        url = 'https://www.kateheddleston.com/blog/{}'.format(gallery_uuid)
        update_facebook_comments(url, gallery_uuid)
        tweets = tweets + update_tweet_comments(url, gallery_uuid)
    return tweets
Esempio n. 12
0
def create_gallery():
    data = json.loads(request.data)
    try:
        gallery = Gallery.create_gallery(**data)
    except ValueError as e:
        flash(e.message, 'danger')
        return json.dumps({'message': e.message}), 400, {
            'Content-Type': 'application/json'
        }
    return json.dumps(gallery.to_dict(admin=True)), 200, {
        'Content-Type': 'application/json'
    }
Esempio n. 13
0
def edit_gallery(uuid):
    gallery = Gallery.get_gallery(uuid)
    g.nav_view = 'galleries'
    policy = base64.b64encode(json.dumps(policy_document))
    signature = base64.b64encode(hmac.new(config.AWS_SECRET_ACCESS_KEY, policy, hashlib.sha1).digest())
    access_key = config.AWS_ACCESS_KEY_ID
    return render_template('admin/edit_gallery.html',
                           gallery=gallery,
                           gallery_json=json.dumps(gallery),
                           policy=policy,
                           signature=signature,
                           accessKey=access_key)
def update_gallery_images():
    galleries = Gallery.get_galleries(published=False)
    for gallery in galleries:
        for item in gallery.get('items', []):
            if item.get('image_name'):
                print "{}    {}".format(gallery.get('uuid'), item.get('image_name'))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), item.get('image_name'))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), "{}_thumbnail".format(item.get('image_name')))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), "{}_small".format(item.get('image_name')))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), "{}_medium".format(item.get('image_name')))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), "{}_large".format(item.get('image_name')))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), "{}_grande".format(item.get('image_name')))
                update_image_headers('galleries/{}'.format(gallery.get('uuid')), "{}_jumbo".format(item.get('image_name')))
Esempio n. 15
0
def blog_post(uuid):
    post = Gallery.get_gallery(uuid)
    return render_template('post.html', post=post, post_json=json.dumps(post))
Esempio n. 16
0
def api_edit_gallery(uuid=None):
    if uuid:
        gallery = Gallery.get(uuid=uuid).to_dict(admin=True)
    else:
        gallery = Gallery.blank()
    return json.dumps(gallery), 200, {'Content-Type': 'application/json'}
Esempio n. 17
0
def get_admin_gallery(uuid=None):
    gallery = Gallery.blank()
    return json.dumps(gallery), 200, {'Content-Type': 'application/json'}
Esempio n. 18
0
def blog():
    g.nav_view = 'blog'
    posts = Gallery.get_list(published=True, to_json=True, sort_by='published_at')
    return render_template('blog.html', posts=posts)
Esempio n. 19
0
def about():
    g.nav_view = 'about'
    gallery = Gallery.get_gallery(uuid='7baf4d66-afa2-46dd-8fee-8b113d255d14')
    return render_template('about.html', gallery=json.dumps(gallery))
Esempio n. 20
0
def contact():
    g.nav_view = 'contact'
    gallery = Gallery.get(uuid='3d93674d-8331-4ac1-a318-26c7bb415fd9')
    return render_template('contact.html', gallery=gallery.to_dict(), gallery_uuid='3d93674d-8331-4ac1-a318-26c7bb415fd9', contact=True)
Esempio n. 21
0
def get_admin_gallery(uuid=None):
    gallery = Gallery.blank()
    return json.dumps(gallery), 200, {'Content-Type': 'application/json'}
Esempio n. 22
0
def contact():
    g.nav_view = 'contact'
    gallery = Gallery.get(uuid='3d93674d-8331-4ac1-a318-26c7bb415fd9')
    return render_template('contact.html', gallery=gallery.to_dict(), gallery_uuid='3d93674d-8331-4ac1-a318-26c7bb415fd9', contact=True)
Esempio n. 23
0
def api_get_galleries():
    galleries = Gallery.get_list(published=False,
                                 to_json=True,
                                 sort_by='published_at')
    return json.dumps(galleries), 200, {'Content-Type': 'application/json'}
Esempio n. 24
0
def send_gallery_emails(uuid):
    Gallery.send_emails(uuid)
    return json.dumps({'message': 'Emails were successfully sent.'}), 200, {
        'Content-Type': 'application/json'
    }
Esempio n. 25
0
def delete_gallery(uuid):
    Gallery.delete(uuid=uuid)
    return_data = {'message': 'Your gallery was successfully deleted.'}
    return json.dumps(return_data), 200, {'Content-Type': 'application/json'}
Esempio n. 26
0
def update_gallery(uuid=None):
    data = json.loads(request.data)
    gallery = Gallery.update(uuid, **data)
    return json.dumps(gallery.to_dict(admin=True)), 200, {
        'Content-Type': 'application/json'
    }
Esempio n. 27
0
def api_edit_gallery(uuid=None):
    if uuid:
        gallery = Gallery.get(uuid=uuid).to_dict(admin=True)
    else:
        gallery = Gallery.blank()
    return json.dumps(gallery), 200, {'Content-Type': 'application/json'}
Esempio n. 28
0
def send_gallery_emails(uuid):
    Gallery.send_emails(uuid)
    return json.dumps({'message': 'Emails were successfully sent.'}), 200, {'Content-Type': 'application/json'}
Esempio n. 29
0
def preview_gallery(uuid):
    gallery = Gallery.get_gallery(uuid)
    g.nav_view = 'galleries'
    return render_template('admin/preview.html', post=gallery, post_json=json.dumps(gallery))
Esempio n. 30
0
def update_gallery(uuid=None):
    data = json.loads(request.data)
    gallery = Gallery.update(uuid, **data)
    return json.dumps(gallery.to_dict(admin=True)), 200, {'Content-Type': 'application/json'}
Esempio n. 31
0
def blog():
    g.nav_view = 'blog'
    posts = Gallery.get_galleries()
    return render_template('blog.html', posts=posts)
Esempio n. 32
0
def update_gallery(uuid):
    data = json.loads(request.data)
    gallery = Gallery.update_gallery(uuid, **data)
    return json.dumps(gallery), 200, {'Content-Type': 'application/json'}
Esempio n. 33
0
def blog():
    g.nav_view = 'blog'
    posts = Gallery.get_list(published=True, to_json=True, sort_by='published_at')
    return render_template('blog.html', posts=posts)
Esempio n. 34
0
def delete_gallery(uuid):
    Gallery.delete_gallery(uuid)
    return_data = {'message': 'Your gallery was successfully deleted.'}
    return json.dumps(return_data), 200, {'Content-Type': 'application/json'}
Esempio n. 35
0
from app.db.talks import Talk
from app.utils.aws import s3_change_image_resolutions


if __name__ == '__main__':
    db_table = sys.argv[1]
    if len(sys.argv) > 3:
        uuid = sys.argv[2]
        image_route = "{}/{}".format(db_table, uuid)
        filename = sys.argv[3]
        s3_change_image_resolutions(image_route, filename)
    elif len(sys.argv) > 2:
        uuid = sys.argv[2]
        image_route = "{}/{}".format(db_table, uuid)
        if db_table == 'galleries':
            db_item = Gallery.get_gallery(uuid=uuid)
            for item in db_item.get('items', []):
                if item.get('image_name'):
                    print(item.get('image_name'))
                    s3_change_image_resolutions(image_route, item.get('image_name'))
        elif db_table == 'talks':
            db_item = Talk.get_talk(uuid=uuid)
            if db_item.get('image_name'):
                print(db_item.get('image_name'))
                s3_change_image_resolutions(image_route, db_item.get('image_name'))
    else:
        if db_table == 'galleries':
            db_items = Gallery.get_galleries()
            for db_item in db_items:
                image_route = "{}/{}".format(db_table, db_item.get('uuid'))
                for item in db_item.get('items', []):
from app.db.talks import Talk
from app.utils.aws import s3_change_image_resolutions


if __name__ == '__main__':
    db_table = sys.argv[1]
    if len(sys.argv) > 3:
        uuid = sys.argv[2]
        image_route = "{}/{}".format(db_table, uuid)
        filename = sys.argv[3]
        s3_change_image_resolutions(image_route, filename)
    elif len(sys.argv) > 2:
        uuid = sys.argv[2]
        image_route = "{}/{}".format(db_table, uuid)
        if db_table == 'galleries':
            db_item = Gallery.get_gallery(uuid=uuid)
            for item in db_item.get('items', []):
                if item.get('image_name'):
                    print item.get('image_name')
                    s3_change_image_resolutions(image_route, item.get('image_name'))
        elif db_table == 'talks':
            db_item = Talk.get_talk(uuid=uuid)
            if db_item.get('image_name'):
                print db_item.get('image_name')
                s3_change_image_resolutions(image_route, db_item.get('image_name'))
    else:
        if db_table == 'galleries':
            db_items = Gallery.get_galleries()
            for db_item in db_items:
                image_route = "{}/{}".format(db_table, db_item.get('uuid'))
                for item in db_item.get('items', []):
import sys

from app import app
from app.db.subscriptions import Subscription
from app.db.galleries import Gallery

if __name__ == "__main__":
    email = sys.argv[1]
    gallery_uuid = sys.argv[2]
    gallery = Gallery.get(uuid=gallery_uuid)
    with app.app_context():
        Subscription.send_subscription_email(email, gallery)
Esempio n. 38
0
def get_gallery_ajax(uuid):
    gallery = Gallery.get(uuid=uuid)
    return json.dumps(gallery.to_dict()), 200, {
        'Content-Type': 'application/json'
    }
Esempio n. 39
0
def get_gallery_ajax(uuid):
    gallery = Gallery.get(uuid=uuid)
    return json.dumps(gallery.to_dict()), 200, {"Content-Type": "application/json"}
Esempio n. 40
0
def api_get_galleries():
    galleries = Gallery.get_list(published=False, to_json=True, sort_by='published_at')
    return json.dumps(galleries), 200, {'Content-Type': 'application/json'}