Exemple #1
0
    def grouptextpanel(self, request, tl, one, two, module, extra, prog):
        if not self.is_configured():
            return render_to_response(self.baseDir() + 'not_configured.html',
                                      request, {})

        usc = UserSearchController()
        context = {}
        context['program'] = prog

        if request.method == "POST":
            data = {}
            for key in request.POST:
                data[key] = request.POST[key]
            filterObj = UserSearchController().filter_from_postdata(prog, data)

            context['filterid'] = filterObj.id
            context['num_users'] = ESPUser.objects.filter(
                filterObj.get_Q()).distinct().count()
            context['est_time'] = float(context['num_users']) * 1.0 / len(
                settings.TWILIO_ACCOUNT_NUMBERS)
            return render_to_response(self.baseDir() + 'options.html', request,
                                      context)

        context.update(
            usc.prepare_context(prog,
                                target_path='/manage/%s/grouptextpanel' %
                                prog.url))
        return render_to_response(self.baseDir() + 'search.html', request,
                                  context)
Exemple #2
0
    def selectList(self, request, tl, one, two, module, extra, prog):
        """ Select a group of users and generate a list of information
            about them using the generateList view above. """
        usc = UserSearchController()

        context = {}
        context['program'] = prog

        #   If list information was submitted, generate a query filter and
        #   show options for generating a user list
        if request.method == 'POST':
            #   Turn multi-valued QueryDict into standard dictionary
            data = {}
            for key in request.POST:
                data[key] = request.POST[key]
            filterObj = usc.filter_from_postdata(prog, data)

            #   Display list generation options
            form = ListGenForm()
            context.update({
                'form': form,
                'filterid': filterObj.id,
                'num_users': ESPUser.objects.filter(filterObj.get_Q()).distinct().count()
            })
            return render_to_response(self.baseDir()+'options.html', request, context)

        #   Otherwise, render a page that shows the list selection options
        context.update(usc.prepare_context(prog, target_path='/manage/%s/selectList' % prog.url))
        return render_to_response(self.baseDir()+'search.html', request, context)
Exemple #3
0
    def commpanel(self, request, tl, one, two, module, extra, prog):

        usc = UserSearchController()

        context = {}
        context['program'] = prog

        #   If list information was submitted, continue to prepare a message
        if request.method == 'POST':
            #   Turn multi-valued QueryDict into standard dictionary
            data = {}
            for key in request.POST:
                data[key] = request.POST[key]

            ##  Handle normal list selecting submissions
            if ('base_list' in data
                    and 'recipient_type' in data) or ('combo_base_list'
                                                      in data):

                filterObj = usc.filter_from_postdata(prog, data)

                if data['use_checklist'] == '1':
                    (response, unused) = get_user_checklist(
                        request,
                        ESPUser.objects.filter(filterObj.get_Q()).distinct(),
                        filterObj.id,
                        '/manage/%s/commpanel_old' % prog.getUrlBase())
                    return response

                context['filterid'] = filterObj.id
                context['listcount'] = ESPUser.objects.filter(
                    filterObj.get_Q()).distinct().count()
                return render_to_response(self.baseDir() + 'step2.html',
                                          request, (prog, tl), context)

            ##  Prepare a message starting from an earlier request
            elif 'msgreq_id' in data:
                msgreq = MessageRequest.objects.get(id=data['msgreq_id'])
                context['filterid'] = msgreq.recipients.id
                context['listcount'] = msgreq.recipients.getList(
                    ESPUser).count()
                context['from'] = msgreq.sender
                context['subject'] = msgreq.subject
                context['replyto'] = msgreq.special_headers_dict.get(
                    'Reply-To', '')
                context['body'] = msgreq.msgtext
                return render_to_response(self.baseDir() + 'step2.html',
                                          request, (prog, tl), context)

            else:
                raise ESPError(
                    True
                ), 'What do I do without knowing what kind of users to look for?'

        #   Otherwise, render a page that shows the list selection options
        context.update(usc.prepare_context(prog))

        return render_to_response(self.baseDir() + 'commpanel_new.html',
                                  request, (prog, tl), context)
    def commpanel(self, request, tl, one, two, module, extra, prog):

        usc = UserSearchController()

        context = {}

        #   If list information was submitted, continue to prepare a message
        if request.method == 'POST':
            #   Turn multi-valued QueryDict into standard dictionary
            data = {}
            for key in request.POST:
                data[key] = request.POST[key]

            ##  Handle normal list selecting submissions
            if ('base_list' in data and 'recipient_type' in data) or ('combo_base_list' in data):


                filterObj = usc.filter_from_postdata(prog, data)
                sendto_fn_name = usc.sendto_fn_from_postdata(data)
                sendto_fn = MessageRequest.assert_is_valid_sendto_fn_or_ESPError(sendto_fn_name)

                if data['use_checklist'] == '1':
                    (response, unused) = get_user_checklist(request, ESPUser.objects.filter(filterObj.get_Q()).distinct(), filterObj.id, '/manage/%s/commpanel_old' % prog.getUrlBase())
                    return response

                context['filterid'] = filterObj.id
                context['sendto_fn_name'] = sendto_fn_name
                context['listcount'] = self.approx_num_of_recipients(filterObj, sendto_fn)
                return render_to_response(self.baseDir()+'step2.html', request, context)

            ##  Prepare a message starting from an earlier request
            elif 'msgreq_id' in data:
                msgreq = MessageRequest.objects.get(id=data['msgreq_id'])
                context['filterid'] = msgreq.recipients.id
                context['sendto_fn_name'] = msgreq.sendto_fn_name
                sendto_fn = MessageRequest.assert_is_valid_sendto_fn_or_ESPError(msgreq.sendto_fn_name)
                context['listcount'] = self.approx_num_of_recipients(msgreq.recipients, sendto_fn)
                context['from'] = msgreq.sender
                context['subject'] = msgreq.subject
                context['replyto'] = msgreq.special_headers_dict.get('Reply-To', '')
                context['body'] = msgreq.msgtext
                return render_to_response(self.baseDir()+'step2.html', request, context)

            else:
                raise ESPError('What do I do without knowing what kind of users to look for?', log=True)

        #   Otherwise, render a page that shows the list selection options
        context.update(usc.prepare_context(prog))

        return render_to_response(self.baseDir()+'commpanel_new.html', request, context)
    def grouptextpanel(self, request, tl, one, two, module, extra, prog):
        if not self.is_configured():
            return render_to_response(self.baseDir() + 'not_configured.html', request, {})

        usc = UserSearchController()
        context = {}
        context['program'] = prog

        if request.method == "POST":
            data = {}
            for key in request.POST:
                data[key] = request.POST[key]
            filterObj = UserSearchController().filter_from_postdata(prog, data)

            context['filterid'] = filterObj.id
            context['num_users'] = ESPUser.objects.filter(filterObj.get_Q()).distinct().count()
            context['est_time'] = float(context['num_users']) * 1.0 / len(settings.TWILIO_ACCOUNT_NUMBERS)
            return render_to_response(self.baseDir()+'options.html', request, context)

        context.update(usc.prepare_context(prog, target_path='/manage/%s/grouptextpanel' % prog.url))
        return render_to_response(self.baseDir()+'search.html', request, context)