Exemple #1
0
 def test_from_shibboleth(self, shib_meta):
     self.user.shib = shib_meta
     Institution.objects.create(
         name='Insitute',
         identifiers=[
             'shib:{}'.format(shib_meta.get('username').split('!')[0])
         ],
         repository=self.repository)
     assert get_preselected_repository(self.user,
                                       self.repositories) == self.repository
Exemple #2
0
def start_view(request, pk):
    paper = get_object_or_404(
        Paper.objects.prefetch_related(
            'oairecord_set'
        ),
        pk=pk
    )
    repositories_protocol = get_all_repositories_and_protocols(paper, request.user)
    used_protocols = set([proto for repo, proto in repositories_protocol])
    available_repositories = sorted([repo for repo, proto in repositories_protocol], key=lambda r: r.name.lower())
    
    # select the most appropriate repository
    preselected_repository = get_preselected_repository(request.user, available_repositories)
    preselected_protocol = None
    if preselected_repository:
        preselected_protocol = {repo.id : proto for repo, proto in repositories_protocol}.get(preselected_repository.id, None)
    elif len(repositories_protocol) > 0:
        preselected_repository = repositories_protocol[0][0]
        preselected_protocol = repositories_protocol[0][1]

    breadcrumbs = paper.breadcrumbs()
    breadcrumbs.append((_('Deposit'), ''))
    context = {
        'paper': paper,
        'max_file_size': settings.DEPOSIT_MAX_FILE_SIZE,
        'available_repositories': available_repositories,
        'selected_repository': preselected_repository,
        'selected_protocol': preselected_protocol,
        'is_owner': paper.is_owned_by(request.user, flexible=True),
        'breadcrumbs': breadcrumbs,
        'repositoryForm': None,
        'paper_form': PaperDepositForm(
            initial={
                'radioUploadType' : request.GET.get('type')
            }
        ),
        'collapse_doctype' : request.GET.get('type') in ['preprint', 'postprint', 'pdfversion'],
        'used_protocols' : used_protocols,
    }
    return render(request, 'deposit/start.html', context)
Exemple #3
0
 def test_none(self):
     assert get_preselected_repository(self.user, self.repositories) is None
Exemple #4
0
 def test_last(self):
     UserPreferences.objects.create(user=self.user,
                                    last_repository=self.repository)
     assert get_preselected_repository(self.user,
                                       self.repositories) == self.repository