示例#1
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()
示例#2
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
示例#3
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()
示例#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