Esempio n. 1
0
def index_context_listener(sender, context=None):
    """
    Add extra variables into deposit index template to create
    """
    if context:
        context['form'] = UploadForm()
        context['deposition_type'] = None

        if 'c' in request.values:
            try:
                from invenio.modules.communities.models import Community
                c = Community.query.get(request.values.get('c'))

                draft_cache = DepositionDraftCacheManager.get()
                draft_cache.data['communities'] = [
                    {
                        'identifier': c.id,
                        'title': c.title,
                    },
                ]
                del draft_cache.data['c']
                draft_cache.save()
                context['community'] = c
            except Exception:
                context['community'] = None
            except ImportError:
                # Community module not installed
                pass
Esempio n. 2
0
 def _prefill_draft(obj, eng):
     if not getattr(request, 'is_api_request', False):
         draft_cache = DepositionDraftCacheManager.get()
         if draft_cache.has_data():
             d = Deposition(obj)
             draft_cache.fill_draft(d, draft_id, clear=clear)
             d.update()
Esempio n. 3
0
def _build_integrate_draft(project, selected_records):
    from lw_daap.modules.invenio_deposit.models \
        import DepositionDraftCacheManager

    rel_dataset = []
    rel_software = []
    for recid in selected_records:
        r = get_record(recid)
        rec_info = {
            'title': '%s (record id: %s)' % (r.get('title'), recid),
            'identifier': recid,
        }
        if r.get('upload_type') == 'dataset':
            rel_dataset.append(rec_info)
        elif r.get('upload_type') == 'software':
            rel_software.append(rec_info)
    current_app.logger.debug(rel_dataset)
    current_app.logger.debug(rel_software)
    draft_cache = DepositionDraftCacheManager.get()
    draft_cache.data['project'] = project.id
    draft_cache.data['record_curated_in_project'] = True
    draft_cache.data['record_public_from_project'] = False
    draft_cache.data['rel_dataset'] = rel_dataset
    draft_cache.data['rel_software'] = rel_software
    draft_cache.save()
Esempio n. 4
0
def index_context_listener(sender, context=None):
    """
    Add extra variables into deposit index template to create
    """
    if context:
        context['form'] = UploadForm()
        context['deposition_type'] = None

        if 'c' in request.values:
            try:
                from invenio.modules.communities.models import Community
                c = Community.query.get(request.values.get('c'))

                draft_cache = DepositionDraftCacheManager.get()
                draft_cache.data['communities'] = [{
                    'identifier': c.id,
                    'title': c.title,
                }, ]
                del draft_cache.data['c']
                draft_cache.save()
                context['community'] = c
            except Exception:
                context['community'] = None
            except ImportError:
                # Community module not installed
                pass
Esempio n. 5
0
def deposit(project_id, deposition_type):
    project = Project.query.get_or_404(project_id)
    if not project.is_user_allowed():
        flash('Only the owner of the project can deposit records on it',
              category='error')
        abort(404)

    from lw_daap.modules.invenio_deposit.models \
        import DepositionDraftCacheManager
    draft_cache = DepositionDraftCacheManager.get()
    draft_cache.data['project'] = project_id
    curated = deposition_type.lower() != 'dataset'
    draft_cache.data['record_curated_in_project'] = curated
    draft_cache.data['record_public_from_project'] = False
    draft_cache.save()

    return redirect(url_for('webdeposit.create',
                    deposition_type=deposition_type, next=next))