示例#1
0
def new():
    """
    Create or edit a collection.
    """
    uid = current_user.get_id()
    form = CollectionForm(request.values, crsf_enabled=False)

    ctx = mycollections_ctx(uid)
    ctx.update({
        'form': form,
        'is_new': True,
        'usercollection': None,
    })

    if request.method == 'POST' and form.validate():
        # Map form
        data = form.data
        data['id'] = data['identifier']
        del data['identifier']
        u = UserCollection(id_user=uid, **data)
        db.session.add(u)
        db.session.commit()
        u.save_collections()
        flash("Community collection was successfully created.",
              category='success')
        return redirect(url_for('.index'))

    return render_template("usercollection_new.html", **ctx)
def new():
    """
    Create or edit a collection.
    """
    uid = current_user.get_id()
    form = CollectionForm(request.values, crsf_enabled=False)

    ctx = mycollections_ctx(uid)
    ctx.update({
        'form': form,
        'is_new': True,
        'usercollection': None,
    })

    if request.method == 'POST' and form.validate():
        # Map form
        data = form.data
        data['id'] = data['identifier']
        del data['identifier']
        u = UserCollection(id_user=uid, **data)
        db.session.add(u)
        db.session.commit()
        u.save_collections()
        flash("Community collection was successfully created.", category='success')
        return redirect(url_for('.index'))

    return render_template(
        "usercollection_new.html",
        **ctx
    )
示例#3
0
def openaire_upload_notification(recid):
    """
    Send a notification to all user collections.
    """
    ctx = {
        'record': get_record(recid),
    }

    ucolls = UserCollection.from_recid(recid, provisional=True)
    for c in ucolls:
        try:
            if c.owner.email:
                ctx.update({
                    'usercollection': c,
                })
                content = render_template_to_string(
                    "usercollection_new_upload_email.html", **ctx)
                send_email(CFG_SITE_SUPPORT_EMAIL,
                           c.owner.email.encode('utf8'),
                           "[%s] New upload to %s" %
                           (CFG_SITE_NAME, c.title.encode('utf8')),
                           content=content.encode('utf8'))
                logger.info("Sent email for new record %s to %s." %
                            (recid, c.owner.email.encode('utf8')))
        except AttributeError:
            pass
示例#4
0
def openaire_upload_notification(recid):
    """
    Send a notification to all user collections.
    """
    ctx = {
        'record': get_record(recid),
    }

    ucolls = UserCollection.from_recid(recid, provisional=True)
    for c in ucolls:
        try:
            if c.owner.email:
                ctx.update({
                    'usercollection': c,
                })
                content = render_template_to_string("usercollection_new_upload_email.html", **ctx)
                send_email(CFG_SITE_SUPPORT_EMAIL, c.owner.email.encode('utf8'), "[%s] New upload to %s" % (CFG_SITE_NAME, c.title.encode('utf8')), content=content.encode('utf8'))
                logger.info("Sent email for new record %s to %s." % (recid, c.owner.email.encode('utf8')))
        except AttributeError:
            pass