def approve_dataset(source_url_hash): # get the MetaTable row and change the approved_status and bounce back to view-datasets. meta = session.query(MetaTable).get(source_url_hash) json_data_types = None if ((not meta.is_socrata_source) and meta.contributed_data_types): json_data_types = json.loads(meta.contributed_data_types) add_dataset_task.delay(source_url_hash, data_types=json_data_types) upd = {'approved_status': 'true'} meta.approved_status = 'true' session.commit() # Email the user who submitted that their dataset has been approved. # email the response to somebody msg_body = """Hello %s,\r\n \r\n Your dataset has been approved and added to Plenar.io:\r\n \r\n %s\r\n \r\n It should appear on http://plenar.io within 24 hours.\r\n \r\n Thank you!\r\n The Plenario Team\r\n http://plenar.io""" % (meta.contributor_name, meta.human_name) send_mail(subject="Your dataset has been added to Plenar.io", recipient=meta.contributor_email, body=msg_body)
def contrib_view(): dataset_info = {} errors = [] socrata_source = False url = "" dataset_id = None md = None if request.args.get('dataset_url'): url = request.args.get('dataset_url') (dataset_info, errors, socrata_source) = get_context_for_new_dataset(url) # check if dataset with the same URL has already been loaded dataset_id = md5(url).hexdigest() md = session.query(MetaTable).get(dataset_id) if md: errors.append("A dataset with that URL has already been loaded: '%s'" % md.human_name) if request.method == 'POST' and not md: md = add_dataset_to_metatable(request, url, dataset_id, dataset_info, socrata_source, approved_status=False) # email a confirmation to the submitter msg_body = """Hello %s,\r\n\r\n We received your recent dataset submission to Plenar.io:\r\n\r\n%s\r\n\r\n After we review it, we'll notify you when your data is loaded and available.\r\n\r\n Thank you!\r\nThe Plenario Team\r\nhttp://plenar.io""" % (request.form.get('contributor_name'), md.human_name) send_mail(subject="Your dataset has been submitted to Plenar.io", recipient=request.form.get('contributor_email'), body=msg_body) return redirect(url_for('views.contrib_thankyou')) context = {'dataset_info': dataset_info, 'form': request.form, 'errors': errors, 'socrata_source': socrata_source} return render_template('contribute.html', **context)
def approve_dataset(source_url_hash): # get the MetaTable row and change the approved_status and bounce back to view-datasets. meta = session.query(MetaTable).get(source_url_hash) json_data_types = None if ((not meta.is_socrata_source) and meta.contributed_data_types): json_data_types = json.loads(meta.contributed_data_types) add_dataset_task.delay(source_url_hash, data_types=json_data_types) upd = { 'approved_status': 'true' } meta.approved_status = 'true' session.commit() # Email the user who submitted that their dataset has been approved. # email the response to somebody msg_body = """Hello %s,\r\n \r\n Your dataset has been approved and added to Plenar.io:\r\n \r\n %s\r\n \r\n It should appear on http://plenar.io within 24 hours.\r\n \r\n Thank you!\r\n The Plenario Team\r\n http://plenar.io""" % (meta.contributor_name, meta.human_name) send_mail(subject="Your dataset has been added to Plenar.io", recipient=meta.contributor_email, body=msg_body)
def send_submission_email(dataset_name, contributor_name, contributor_email): msg_body = """Hello %s,\r\n\r\n We received your recent dataset submission to Plenar.io:\r\n\r\n%s\r\n\r\n After we review it, we'll notify you when your data is loaded and available.\r\n\r\n Thank you!\r\nThe Plenario Team\r\nhttp://plenar.io""" % (contributor_name, dataset_name) send_mail(subject="Your dataset has been submitted to Plenar.io", recipient=contributor_email, body=msg_body) return redirect(url_for('views.contrib_thankyou'))
def contrib_view(): dataset_info = {} errors = [] socrata_source = False url = "" dataset_id = None md = None if request.args.get('dataset_url'): url = request.args.get('dataset_url') (dataset_info, errors, socrata_source) = get_context_for_new_dataset(url) # check if dataset with the same URL has already been loaded dataset_id = md5(url).hexdigest() md = session.query(MetaTable).get(dataset_id) if md: errors.append( "A dataset with that URL has already been loaded: '%s'" % md.human_name) if request.method == 'POST' and not md: md = add_dataset_to_metatable(request, url, dataset_id, dataset_info, socrata_source, approved_status=False) # email a confirmation to the submitter msg_body = """Hello %s,\r\n\r\n We received your recent dataset submission to Plenar.io:\r\n\r\n%s\r\n\r\n After we review it, we'll notify you when your data is loaded and available.\r\n\r\n Thank you!\r\nThe Plenario Team\r\nhttp://plenar.io""" % ( request.form.get('contributor_name'), md.human_name) send_mail(subject="Your dataset has been submitted to Plenar.io", recipient=request.form.get('contributor_email'), body=msg_body) return redirect(url_for('views.contrib_thankyou')) context = { 'dataset_info': dataset_info, 'form': request.form, 'errors': errors, 'socrata_source': socrata_source } return render_template('contribute.html', **context)
def send_approval_email(dataset_name, contributor_name, contributor_email): # Email the submitter msg_body = """Hello %s,\r\n \r\n Your dataset has been approved and added to Plenar.io:\r\n \r\n %s\r\n \r\n It should appear on http://plenar.io within 24 hours.\r\n \r\n Thank you!\r\n The Plenario Team\r\n http://plenar.io""" % (contributor_name, dataset_name) send_mail(subject="Your dataset has been added to Plenar.io", recipient=contributor_email, body=msg_body)
def send_approval_email(dataset_name, contributor_name, contributor_email): # Email the submitter # TODO: this really should be a template that jinja loads up and then we send the interpolated string msg_body = """Hello %s,\r\n \r\n Your dataset has been approved and added to Plenar.io:\r\n \r\n %s\r\n \r\n It should appear on http://plenar.io within 24 hours.\r\n \r\n Thank you!\r\n The Plenario Team\r\n http://plenar.io""" % (contributor_name, dataset_name) send_mail(subject="Your dataset has been added to Plenar.io", recipient=contributor_email, body=msg_body)