Exemplo n.º 1
0
    def post(self, request):

        try:
            podcasts = self._get_podcasts(request)

        except InvalidPodcast as ip:
            messages.error(request,
                           _("No podcast with URL {url}").format(url=str(ip)))

        grouper = PodcastGrouper(podcasts)

        features = {}
        for key, feature in request.POST.items():
            m = self.RE_EPISODE.match(key)
            if m:
                episode_id = m.group(1)
                features[episode_id] = feature

        get_features = lambda id_e: (features.get(id_e[0], id_e[0]), id_e[0])

        num_groups = grouper.group(get_features)

        if "renew" in request.POST:
            return render(
                request,
                "admin/merge-grouping.html",
                {
                    "podcasts": podcasts,
                    "groups": num_groups
                },
            )

        elif "merge" in request.POST:

            podcast_ids = [p.get_id() for p in podcasts]
            num_groups = list(num_groups)

            res = merge_podcasts.delay(podcast_ids, num_groups)

            return HttpResponseRedirect(
                reverse("admin-merge-status", args=[res.task_id]))
Exemplo n.º 2
0
    def post(self, request):

        try:
            podcasts = self._get_podcasts(request)

        except InvalidPodcast as ip:
            messages.error(request, _('No podcast with URL {url}').format(url=str(ip)))

        grouper = PodcastGrouper(podcasts)

        features = {}
        for key, feature in request.POST.items():
            m = self.RE_EPISODE.match(key)
            if m:
                episode_id = m.group(1)
                features[episode_id] = feature

        get_features = lambda id_e: (features.get(id_e[0], id_e[0]), id_e[0])

        num_groups = grouper.group(get_features)

        if 'renew' in request.POST:
            return render(
                request,
                'admin/merge-grouping.html',
                {'podcasts': podcasts, 'groups': num_groups},
            )

        elif 'merge' in request.POST:

            podcast_ids = [p.get_id() for p in podcasts]
            num_groups = list(num_groups)

            res = merge_podcasts.delay(podcast_ids, num_groups)

            return HttpResponseRedirect(
                reverse('admin-merge-status', args=[res.task_id])
            )