Exemplo n.º 1
0
def get_comments_for_talks():
    talks = Talk.get_list(published=True)
    tweets = []
    for talk in talks:
        talk_uuid = talk.uuid
        url = 'https://www.kateheddleston.com/talks/{}'.format(talk_uuid)
        update_facebook_comments(url, talk_uuid)
        tweets = tweets + update_tweet_comments(url, talk_uuid)
Exemplo n.º 2
0
def get_comments_for_talks():
    talks = Talk.get_list(published=True)
    tweets = []
    for talk in talks:
        talk_uuid = talk.uuid
        url = 'https://www.kateheddleston.com/talks/{}'.format(talk_uuid)
        update_facebook_comments(url, talk_uuid)
        tweets = tweets + update_tweet_comments(url, talk_uuid)
Exemplo n.º 3
0
def create_talk():
    data = json.loads(request.data)
    date = data.get('date')
    if date:
        date = datetime.datetime.strptime(date, '%B %d, %Y')
        data['date'] = date
    try:
        talk = Talk.create_talk(**data)
    except ValueError as e:
        flash(e.message, 'danger')
        return json.dumps({'message': e.message}), 400, {'Content-Type': 'application/json'}
    return json.dumps(talk), 200, {'Content-Type': 'application/json'}
Exemplo n.º 4
0
def create_talk():
    data = json.loads(request.data)
    date = data.get('date')
    if date:
        date = datetime.datetime.strptime(date, '%B %d, %Y')
        data['date'] = date
    try:
        talk = Talk.create(**data)
    except ValueError as e:
        flash(e.message, 'danger')
        return json.dumps({'message': e.message}), 400, {
            'Content-Type': 'application/json'
        }
    return json.dumps(talk.to_dict()), 200, {
        'Content-Type': 'application/json'
    }
Exemplo n.º 5
0
 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', []):
                 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_items = Talk.get_talks()
         for db_item in db_items:
Exemplo n.º 6
0
def delete_talk(uuid):
    Talk.delete_talk(uuid)
    return_data = {'message': 'Your talk was successfully deleted.'}
    return json.dumps(return_data), 200, {'Content-Type': 'application/json'}
Exemplo n.º 7
0
def edit_talk(uuid):
    data = json.loads(request.data)
    talk = Talk.update_talk(uuid, **data)
    return json.dumps(talk), 200, {'Content-Type': 'application/json'}
Exemplo n.º 8
0
def delete_talk(uuid):
    Talk.delete(uuid=uuid)
    return_data = {'message': 'Your talk was successfully deleted.'}
    return json.dumps(return_data), 200, {'Content-Type': 'application/json'}
Exemplo n.º 9
0
def talk(uuid):
    talk = Talk.get(uuid=uuid)
    if not talk:
        abort(404)
    return render_template('talk.html', talk=talk.to_dict())
Exemplo n.º 10
0
def talk(uuid):
    talk = Talk.get(uuid=uuid)
    if not talk:
        abort(404)
    return render_template('talk.html', talk=talk.to_dict())
Exemplo n.º 11
0
def api_get_talks():
    talks = Talk.get_list(published=False, to_json=True, sort_by='date')
    return json.dumps(talks), 200, {'Content-Type': 'application/json'}
Exemplo n.º 12
0
def get_talks():
    if request.is_xhr:
        talks = Talk.get_talks(published=False)
        return json.dumps(talks), 200, {'Content-Type': 'application/json'}
    g.nav_view = 'talks'
    return render_template('admin/talks.html')
Exemplo n.º 13
0
def api_edit_talk(uuid=None):
    if uuid:
        talk = Talk.get(uuid=uuid).to_dict()
    else:
        talk = Talk.blank()
    return json.dumps(talk), 200, {'Content-Type': 'application/json'}
Exemplo n.º 14
0
def api_get_talks():
    talks = Talk.get_list(published=False, to_json=True, sort_by='date')
    return json.dumps(talks), 200, {'Content-Type': 'application/json'}
 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', []):
                 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_items = Talk.get_talks()
         for db_item in db_items:
Exemplo n.º 16
0
def talk(uuid):
    talk = Talk.get_talk(uuid)
    return render_template('talk.html', talk=talk)
Exemplo n.º 17
0
def talks():
    g.nav_view = 'talks'
    talks = Talk.get_talks()
    return render_template('talks.html', talks=talks)
Exemplo n.º 18
0
def talks():
    g.nav_view = 'talks'
    talks = Talk.get_list(published=True, sort_by='date', to_json=True)
    return render_template('talks.html', talks=talks)
Exemplo n.º 19
0
def api_edit_talk(uuid=None):
    if uuid:
        talk = Talk.get(uuid=uuid).to_dict()
    else:
        talk = Talk.blank()
    return json.dumps(talk), 200, {'Content-Type': 'application/json'}
Exemplo n.º 20
0
def update_talk(uuid):
    data = json.loads(request.data)
    talk = Talk.update_talk(uuid, **data)
    return json.dumps(talk.to_dict()), 200, {
        'Content-Type': 'application/json'
    }
Exemplo n.º 21
0
def talks():
    g.nav_view = 'talks'
    talks = Talk.get_list(published=True, sort_by='date', to_json=True)
    return render_template('talks.html', talks=talks)