def get_context_data(self, **kwargs): preprint = PreprintService.load(self.kwargs.get('guid')) # TODO - we shouldn't need this serialized_preprint value -- https://openscience.atlassian.net/browse/OSF-7743 kwargs['serialized_preprint'] = serialize_preprint(preprint) kwargs['change_provider_form'] = ChangeProviderForm(instance=preprint) kwargs['subjects'] = serialize_subjects(preprint.subject_hierarchy) return super(PreprintView, self).get_context_data(**kwargs)
def test_change_preprint_provider_form(self): new_provider = PreprintProviderFactory() self.view.kwargs = {'guid': self.preprint._id} form_data = {'provider': new_provider.id} form = ChangeProviderForm(data=form_data, instance=self.preprint) self.view().form_valid(form) nt.assert_equal(self.preprint.provider, new_provider)
def test_change_preprint_provider_form(self, plain_view, preprint): new_provider = PreprintProviderFactory() plain_view.kwargs = {'guid': preprint._id} form_data = {'provider': new_provider.id} form = ChangeProviderForm(data=form_data, instance=preprint) plain_view().form_valid(form) assert preprint.provider == new_provider
def get_context_data(self, **kwargs): preprint = PreprintService.load(self.kwargs.get('guid')) # TODO - we shouldn't need this serialized_preprint value -- https://openscience.atlassian.net/browse/OSF-7743 kwargs['serialized_preprint'] = serialize_preprint(preprint) kwargs['change_provider_form'] = ChangeProviderForm(instance=preprint) kwargs.update({'SPAM_STATUS': SpamStatus}) # Pass spam status in to check against return super(PreprintView, self).get_context_data(**kwargs)
def get_context_data(self, **kwargs): preprint = self.get_object() return super().get_context_data( **{ 'preprint': preprint, 'SPAM_STATUS': SpamStatus, 'form': ChangeProviderForm(instance=preprint), }, **kwargs)