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

        try:
            podcasts = self._get_podcasts(request)

            grouper = PodcastGrouper(podcasts)

            get_features = lambda id_e: ((id_e[1].url, id_e[1].title), id_e[0])

            num_groups = grouper.group(get_features)

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

            podcasts = []
            num_groups = []

        return self.render_to_response({'podcasts': podcasts, 'groups': num_groups})
Ejemplo 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]))
Ejemplo n.º 3
0
    def post(self, request):

        try:
            podcasts = self._get_podcasts(request)

            grouper = PodcastGrouper(podcasts)

            get_features = lambda id_e: ((id_e[1].url, id_e[1].title), id_e[0])

            num_groups = grouper.group(get_features)

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

            podcasts = []
            num_groups = []

        return self.render_to_response({
            'podcasts': podcasts,
            'groups': num_groups,
        })
Ejemplo n.º 4
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])
            )
Ejemplo n.º 5
0
    def post(self, request):

        try:
            podcasts = self._get_podcasts(request)

            grouper = PodcastGrouper(podcasts)

            def get_features(id_id):
                e = Episode.objects.get(pk=id_id[0])
                return ((e.url, e.title), id_id[0])

            num_groups = grouper.group(get_features)

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

            podcasts = []
            num_groups = []

        return self.render_to_response({
            "podcasts": podcasts,
            "groups": num_groups
        })