Exemplo n.º 1
0
    def get_context_data(self, **kwargs):

        context = super(UpdateArtworkView, self).get_context_data(**kwargs)
        context['action'] = reverse('artwork-edit',
                                    kwargs={'pk': self.get_object().id})

        artwork = context['object']
        if artwork:
            context['share_url'] = ShareView.get_share_url(
                artwork.get_absolute_url())

            submissions_qs = Submission.objects.filter(
                artwork__exact=artwork.id).order_by('-created_at').all()
            submissions = {int(x.exhibition_id): x for x in submissions_qs}

            exhibitions_qs = Exhibition.can_see_queryset(
                Exhibition.objects,
                self.request.user).order_by('-released_at', 'created_at')
            exhibitions = exhibitions_qs.all()

            # Collect the exhibitions we've already submitted this artwork to,
            # and the ones that can still be submitted to
            context['exhibitions_submitted'] = []
            context['exhibitions_to_submit'] = []
            for exh in exhibitions:
                submission = submissions.get(exh.id)
                if submission:
                    exh.submitted = submission
                    context['exhibitions_submitted'].append(exh)
                else:
                    context['exhibitions_to_submit'].append(exh)

        return context
Exemplo n.º 2
0
    def get_context_data(self, **kwargs):

        context = super(UpdateArtworkView, self).get_context_data(**kwargs)
        context['action'] = reverse('artwork-edit',
                                    kwargs={'pk': self.get_object().id})

        artwork = context['object']
        if artwork:
            context['share_url'] = ShareView.get_share_url(artwork.get_absolute_url())

            submissions_qs = Submission.objects.filter(
                artwork__exact=artwork.id).order_by('-created_at').all()
            submissions = { int(x.exhibition_id) : x for x in submissions_qs }

            exhibitions_qs = Exhibition.can_see_queryset(
                Exhibition.objects,
                self.request.user).order_by('-released_at', 'created_at')
            exhibitions = exhibitions_qs.all()

            # Collect the exhibitions we've already submitted this artwork to,
            # and the ones that can still be submitted to
            context['exhibitions_submitted'] = []
            context['exhibitions_to_submit'] = []
            for exh in exhibitions:
                submission = submissions.get(exh.id)
                if submission:
                    exh.submitted = submission
                    context['exhibitions_submitted'].append(exh)
                else:
                    context['exhibitions_to_submit'].append(exh)

        return context
    def test_get_share_url_home(self):
        home_path = reverse('home')
        share_url = ShareView.get_share_url(home_path)
        home_url = '%s%s' % (self.live_server_url, home_path)

        # Ensure redirects to home
        self.selenium.get(share_url)
        time.sleep(1)
        self.assertEqual(self.selenium.current_url, home_url)
    def test_get_share_url_home(self):
        home_path = reverse('home')
        share_url = ShareView.get_share_url(home_path)
        home_url = '%s%s' % (self.live_server_url, home_path)

        # Ensure redirects to home
        self.selenium.get(share_url)
        time.sleep(1)
        self.assertEqual(self.selenium.current_url, home_url)
 def test_share_url_home_redirects(self):
     share_url = ShareView.get_share_url(reverse('home'))
     self.assertShareUrlRedirects(share_url)
 def test_share_url_redirect(self):
     share_url = ShareView.get_share_url()
     self.assertShareUrlRedirects(share_url)
 def test_share_url_home_redirects(self):
     share_url = ShareView.get_share_url(reverse('home'))
     self.assertShareUrlRedirects(share_url)
 def test_share_url_redirect(self):
     share_url = ShareView.get_share_url()
     self.assertShareUrlRedirects(share_url)