Пример #1
0
 def __init__(self, *args, **kwargs):
     super(AlarmForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-6'
     self.helper.layout = Layout(
         Div(
             Div('name', css_class=css_class),
             Div('period', css_class=css_class),
             css_class='row',
         ),
         Div(
             Div('type', css_class=css_class),
             Div('alert_condition', css_class=css_class),
             css_class='row',
         ),
         Div(
             Div('alert_value', css_class=css_class),
             Div('alert_condition_add_on', css_class=css_class),
             css_class='row',
         ),
         Div(
             Div('status', css_class=css_class),
             Div('email_to_send_alarm', css_class=css_class),
             css_class='row',
         ),
     )
     if self.instance.id:
         common_submit_buttons(self.helper.layout, 'update')
     else:
         common_submit_buttons(self.helper.layout)
Пример #2
0
 def __init__(self, *args, **kwargs):
     super(AlarmForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-6'
     self.helper.layout = Layout(
         Div(
             Div('name', css_class=css_class),
             Div('period', css_class=css_class),
             css_class='row',
         ),
         Div(
             Div('type', css_class=css_class),
             Div('alert_condition', css_class=css_class),
             css_class='row',
         ),
         Div(
             Div('alert_value', css_class=css_class),
             Div('alert_condition_add_on', css_class=css_class),
             css_class='row',
         ),
         Div(
             Div('status', css_class=css_class),
             Div('email_to_send_alarm', css_class=css_class),
             css_class='row',
         ),
     )
     if self.instance.id:
         common_submit_buttons(self.helper.layout, 'update')
     else:
         common_submit_buttons(self.helper.layout)
Пример #3
0
    def __init__(self, user, *args, **kwargs):
        super(EventForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-6'
        self.helper.layout = Layout(
            Fieldset(_('event settings').capitalize()),
            Div(Div('title', css_class=css_class),
                Div('calendar', css_class=css_class),
                Div('creator', css_class=css_class),
                Div('created_on', css_class=css_class),
                Div('rule', css_class=css_class),
                Div('end_recurring_period', css_class=css_class),
                Div('start', css_class=css_class),
                Div('end', css_class=css_class),
                css_class='row'),
            Div(Div('description', css_class=css_class),
                Div('data', css_class=css_class),
                css_class='row'),
        )
        if self.instance.id:
            common_submit_buttons(self.helper.layout, 'update')
        else:
            common_submit_buttons(self.helper.layout)

        calendar_user_list = get_calendar_user_id_list(user)
        self.fields['calendar'].choices = get_calendar_list(calendar_user_list)
        self.fields['creator'].choices = get_calendar_user_list(
            calendar_user_list)
Пример #4
0
    def __init__(self, user, *args, **kwargs):
        super(SurveyDetailReportForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-4'
        self.helper.layout = Layout(
            Div(
                Div('survey_id', css_class=css_class),
                Div('from_date', css_class=css_class),
                Div('to_date', css_class=css_class),
                css_class='row'
            ),
        )
        common_submit_buttons(self.helper.layout, 'search')

        if user:
            survey_list = []
            survey_list.append((0, _('select survey').title()))
            if user.is_superuser:
                survey_objs = Survey.objects.values_list('id', 'name', 'campaign__name').all().order_by('-id')
            else:
                survey_objs = Survey.objects.values_list('id', 'name', 'campaign__name').filter(user=user).order_by('-id')

            for i in survey_objs:
                if i[2]:
                    survey_name = i[1] + " : " + i[2]
                else:
                    survey_name = i[1]
                survey_list.append((i[0], survey_name))
            self.fields['survey_id'].choices = survey_list
Пример #5
0
    def __init__(self, user, *args, **kwargs):
        super(EventForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-6'
        self.helper.layout = Layout(
            Fieldset(_('Event Settings')),
            Div(
                Div('title', css_class=css_class),
                Div('calendar', css_class=css_class),
                Div('creator', css_class=css_class),
                Div('created_on', css_class=css_class),
                Div('rule', css_class=css_class),
                Div('end_recurring_period', css_class=css_class),
                Div('start', css_class=css_class),
                Div('end', css_class=css_class),
                css_class='row'
            ),
            Div(
                Div('description', css_class=css_class),
                Div('data', css_class=css_class),
                css_class='row'
            ),
        )
        if self.instance.id:
            common_submit_buttons(self.helper.layout, 'update')
        else:
            common_submit_buttons(self.helper.layout)

        calendar_user_list = get_calendar_user_id_list(user)
        self.fields['calendar'].choices = get_calendar_list(calendar_user_list)
        self.fields['creator'].choices = get_calendar_user_list(calendar_user_list)
Пример #6
0
    def __init__(self, user, *args, **kwargs):
        super(SurveyDetailReportForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-4'
        self.helper.layout = Layout(
            Div(
                Div('survey_id', css_class=css_class),
                Div('from_date', css_class=css_class),
                Div('to_date', css_class=css_class),
                css_class='row'
            ),
        )
        common_submit_buttons(self.helper.layout, 'search')

        if user:
            survey_list = []
            survey_list.append((0, _('Select Survey')))
            if user.is_superuser:
                survey_objs = Survey.objects.values_list('id', 'name', 'campaign__name').all().order_by('-id')
            else:
                survey_objs = Survey.objects.values_list('id', 'name', 'campaign__name')\
                    .filter(user=user).order_by('-id')

            for i in survey_objs:
                if i[2]:
                    survey_name = i[1] + " : " + i[2]
                else:
                    survey_name = i[1]
                survey_list.append((i[0], survey_name))
            self.fields['survey_id'].choices = survey_list
Пример #7
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContact_fileExport, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Div(Fieldset('', 'dnc_list', css_class='col-md-6')),
                css_class='row'),
            Div(Div(HTML("""
                    <b>%s : </b>
                    <div class="btn-group" data-toggle="buttons">
                        {% for choice in form.export_to.field.choices %}
                        <label class="btn btn-default">
                            <input name='{{ form.export_to.name }}' type='radio' value='{{ choice.0 }}'/> {{ choice.1 }}
                        </label>
                        {% endfor %}
                    </div>
                   """ % _('Export to')),
                    css_class='col-md-6'),
                css_class='row'),
        )
        common_submit_buttons(self.helper.layout, 'add')

        # To get user's dnc_list list
        if user:  # and not user.is_superuser
            self.fields['dnc_list'].choices = get_dnc_list(user)
Пример #8
0
    def __init__(self, user, *args, **kwargs):
        super(VoipSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Div('from_date', css_class='col-md-4'),
                Div('to_date', css_class='col-md-4'),
                Div('disposition', css_class='col-md-4'),
                Div('campaign_id', css_class='col-md-4'),
                Div('leg_type', css_class='col-md-4'),
                css_class='row'), )
        common_submit_buttons(self.helper.layout, 'search')

        # To get user's campaign list which are attached with voipcall
        if user:
            self.fields['leg_type'].choices = get_leg_type_list()
            camp_list = []
            camp_list.append((0, _('ALL')))
            content_type_list = ['survey']

            if user.is_superuser:
                # // , has_been_started=True
                campaign_list = Campaign.objects.values_list('id', 'name')\
                    .filter(content_type__model__in=content_type_list)\
                    .order_by('-id')
            else:
                # // , has_been_started=True
                campaign_list = Campaign.objects.values_list('id', 'name')\
                    .filter(user=user, content_type__model__in=content_type_list)\
                    .order_by('-id')

            for i in campaign_list:
                camp_list.append((i[0], i[1]))

            self.fields['campaign_id'].choices = camp_list
Пример #9
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContact_fileExport, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(
                Div(Fieldset('', 'dnc_list', css_class='col-md-6')),
                css_class='row'
            ),
            Div(
                Div(HTML("""
                    <b>%s : </b>
                    <div class="btn-group" data-toggle="buttons">
                        {% for choice in form.export_to.field.choices %}
                        <label class="btn btn-default">
                            <input name='{{ form.export_to.name }}' type='radio' value='{{ choice.0 }}'/> {{ choice.1 }}
                        </label>
                        {% endfor %}
                    </div>
                   """ % _('Export to')), css_class='col-md-6'),
                css_class='row'
            ),
        )
        common_submit_buttons(self.helper.layout, 'add')

        # To get user's dnc_list list
        if user:  # and not user.is_superuser
            self.fields['dnc_list'].choices = get_dnc_list(user)
Пример #10
0
 def __init__(self, *args, **kwargs):
     super(CompareCallSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-3'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('compare_days', css_class=css_class),
             Div('switch_id', css_class=css_class),
             Div('metric', css_class=css_class),
             # Div(HTML("""
             #     <b>Check with* : </b><br/>
             #     <div class="btn-group" data-toggle="buttons">
             #         {% for choice in form.compare_type.field.choices %}
             #         <label class="btn btn-default">
             #             <input name='{{ form.compare_type.name }}' type='radio' value='{{ choice.0 }}'/>
             #             {{ choice.1 }}
             #         </label>
             #         {% endfor %}
             #     </div>
             #    """), css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
Пример #11
0
    def __init__(self, user, *args, **kwargs):
        super(CalendarSettingForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        css_class = 'col-md-6'

        self.helper.layout = Layout(
            Div(
                Div('label', css_class=css_class),
                Div('callerid', css_class=css_class),
                Div('caller_name', css_class=css_class),
                Div('call_timeout', css_class=css_class),
                Div('survey', css_class=css_class),
                Div('aleg_gateway', css_class=css_class),
                Div('sms_gateway', css_class=css_class),
                css_class='row'
            ),
        )
        if settings.AMD:
            self.helper.layout.append(
                Div(
                    Div(
                        HTML("""
                            <div class="btn-group" data-toggle="buttons">
                                <label for="{{ form.voicemail.auto_id }}">{{ form.voicemail.label }}</label><br/>
                                <div class="make-switch switch-small">
                                {{ form.voicemail }}
                                </div>
                            </div>
                            """), css_class='col-md-12 col-xs-10'
                    ),
                    css_class='row'
                ),
            )
            self.helper.layout.append(
                Div(
                    Div('amd_behavior', css_class=css_class),
                    Div('voicemail_audiofile', css_class=css_class),
                    css_class='row'
                )
            )

        if self.instance.id:
            form_action = common_submit_buttons(default_action='update')
        else:
            form_action = common_submit_buttons(default_action='add')

        self.helper.layout.append(form_action)

        list_survey = []
        list_survey.append((0, '---'))
        for l in Survey.objects.values_list('id', 'name').filter(user=user).order_by('id'):
            list_survey.append((l[0], l[1]))
        self.fields['survey'].choices = list_survey

        list_gateway = []
        list_gateway.append((0, '---'))
        for l in UserProfile.objects.get(user=user).userprofile_gateway.all():
            list_gateway.append((l.id, l.name))
        self.fields['aleg_gateway'].choices = list_gateway
Пример #12
0
    def __init__(self, user, *args, **kwargs):
        super(CalendarSettingForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        css_class = 'col-md-6'

        self.helper.layout = Layout(
            Div(
                Div('label', css_class=css_class),
                Div('callerid', css_class=css_class),
                Div('caller_name', css_class=css_class),
                Div('call_timeout', css_class=css_class),
                Div('survey', css_class=css_class),
                Div('aleg_gateway', css_class=css_class),
                Div('sms_gateway', css_class=css_class),
                css_class='row'
            ),
        )
        if settings.AMD:
            self.helper.layout.append(
                Div(
                    Div(
                        HTML("""
                            <div class="btn-group" data-toggle="buttons">
                                <label for="{{ form.voicemail.auto_id }}">{{ form.voicemail.label }}</label><br/>
                                <div class="make-switch switch-small">
                                {{ form.voicemail }}
                                </div>
                            </div>
                            """), css_class='col-md-12 col-xs-10'
                    ),
                    css_class='row'
                ),
            )
            self.helper.layout.append(
                Div(
                    Div('amd_behavior', css_class=css_class),
                    Div('voicemail_audiofile', css_class=css_class),
                    css_class='row'
                )
            )

        if self.instance.id:
            form_action = common_submit_buttons(default_action='update')
        else:
            form_action = common_submit_buttons(default_action='add')

        self.helper.layout.append(form_action)

        list_survey = []
        list_survey.append((0, '---'))
        for l in Survey.objects.values_list('id', 'name').filter(user=user).order_by('id'):
            list_survey.append((l[0], l[1]))
        self.fields['survey'].choices = list_survey

        list_gateway = []
        list_gateway.append((0, '---'))
        for l in UserProfile.objects.get(user=user).userprofile_gateway.all():
            list_gateway.append((l.id, l.name))
        self.fields['aleg_gateway'].choices = list_gateway
Пример #13
0
 def __init__(self, user, *args, **kwargs):
     self.user = user
     super(EmailReportForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(Div('multiple_email', css_class=css_class), css_class='row'), )
     common_submit_buttons(self.helper.layout, 'add')
Пример #14
0
    def __init__(self, *args, **kwargs):
        super(DialerAudioFileForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Fieldset('', 'name', 'audio_file', css_class='col-md-4')), )

        if self.instance.id:
            common_submit_buttons(self.helper.layout, 'update')
        else:
            common_submit_buttons(self.helper.layout)
Пример #15
0
 def __init__(self, *args, **kwargs):
     super(PhonebookForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     self.helper.layout = Layout(
         Div(Div(Fieldset('', 'name', 'description',
                          css_class='col-md-6')), ), )
     if self.instance.id:
         common_submit_buttons(self.helper.layout, 'update')
     else:
         common_submit_buttons(self.helper.layout)
Пример #16
0
    def __init__(self, user, *args, **kwargs):
        super(Contact_fileImport, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Div(Fieldset('', 'phonebook', 'csv_file')), ), )
        common_submit_buttons(self.helper.layout, 'import')

        # To get user's phonebook list
        if user:  # and not user.is_superuser
            self.fields['phonebook'].choices = get_phonebook_list(user)
Пример #17
0
 def __init__(self, *args, **kwargs):
     super(ConcurrentCallForm, self).__init__(*args, **kwargs)
     self.fields['from_date'].label = _('select date').capitalize()
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(Div('from_date', css_class=css_class),
             Div('switch_id', css_class=css_class),
             css_class='row'), )
     common_submit_buttons(self.helper.layout, 'search')
Пример #18
0
 def __init__(self, *args, **kwargs):
     super(WorldForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(Div('from_date', css_class=css_class),
             Div('to_date', css_class=css_class),
             Div('switch_id', css_class=css_class),
             css_class='row'), )
     common_submit_buttons(self.helper.layout, 'search')
Пример #19
0
 def __init__(self, user, *args, **kwargs):
     super(SMSCampaignSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = "well"
     css_class = "col-md-3"
     self.helper.layout = Layout(
         Div(Div("phonebook_id", css_class=css_class), Div("status", css_class=css_class), css_class="row")
     )
     common_submit_buttons(self.helper.layout, "search")
     if user:
         self.fields["phonebook_id"].choices = get_phonebook_list(user)
Пример #20
0
 def __init__(self, manager_id, *args, **kwargs):
     super(TierFrontEndForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = "well"
     self.helper.layout = Layout(Div(Div(Fieldset("", "agent", "queue", "level", "position", css_class="col-md-6"))))
     if self.instance.id:
         common_submit_buttons(self.helper.layout, "update")
     else:
         common_submit_buttons(self.helper.layout)
     self.fields["agent"].choices = agentprofile_list(manager_id)
     self.fields["queue"].choices = queue_list(manager_id)
Пример #21
0
    def __init__(self, *args, **kwargs):
        super(DialerAudioFileForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Fieldset('', 'name', 'audio_file', css_class='col-md-4')),
        )

        if self.instance.id:
            common_submit_buttons(self.helper.layout, 'update')
        else:
            common_submit_buttons(self.helper.layout)
Пример #22
0
 def __init__(self, user, *args, **kwargs):
     super(SMSCampaignSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-3'
     self.helper.layout = Layout(
         Div(Div('phonebook_id', css_class=css_class),
             Div('status', css_class=css_class),
             css_class='row'), )
     common_submit_buttons(self.helper.layout, 'search')
     if user:
         self.fields['phonebook_id'].choices = get_phonebook_list(user)
Пример #23
0
 def __init__(self, user, *args, **kwargs):
     self.user = user
     super(EmailReportForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('multiple_email', css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'add')
Пример #24
0
 def __init__(self, *args, **kwargs):
     super(DNCListForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     self.helper.layout = Layout(
         Div(
             Div(Fieldset('', 'name', 'description', css_class='col-md-6')),
         ),
     )
     if self.instance.id:
         common_submit_buttons(self.helper.layout, 'update')
     else:
         common_submit_buttons(self.helper.layout)
Пример #25
0
 def __init__(self, user, *args, **kwargs):
     super(CalendarForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     self.helper.layout = Layout(
         Fieldset('', 'name', 'user', 'max_concurrent', css_class='col-xs-4')
     )
     if self.instance.id:
         form_action = common_submit_buttons(default_action='update')
     else:
         form_action = common_submit_buttons(default_action='add')
     self.helper.layout.append(form_action)
     calendar_user_list = get_calendar_user_id_list(user)
     self.fields['user'].choices = get_calendar_user_list(calendar_user_list)
Пример #26
0
 def __init__(self, *args, **kwargs):
     super(WorldForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('to_date', css_class=css_class),
             Div('switch_id', css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
Пример #27
0
 def __init__(self, user, *args, **kwargs):
     super(CalendarForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     self.helper.layout = Layout(
         Fieldset('', 'name', 'user', 'max_concurrent', css_class='col-xs-4')
     )
     if self.instance.id:
         form_action = common_submit_buttons(default_action='update')
     else:
         form_action = common_submit_buttons(default_action='add')
     self.helper.layout.append(form_action)
     calendar_user_list = get_calendar_user_id_list(user)
     self.fields['user'].choices = get_calendar_user_list(calendar_user_list)
Пример #28
0
    def __init__(self, *args, **kwargs):
        super(QueueFrontEndForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        css_class = "col-md-6"
        self.helper.form_class = "well"
        boolean_fields = [
            "tier_rules_apply",
            "tier_rule_wait_multiply_level",
            "tier_rule_no_agent_no_wait",
            "abandoned_resume_allowed",
        ]
        boolean_fields_html = """<div class="row"><div class="col-md-12 col-xs-10">"""

        for i in boolean_fields:
            boolean_fields_html += """
                <div class="col-xs-6">
                    <div class="btn-group" data-toggle="buttons">
                        <label for="{{ form.%s.auto_id }}">{{ form.%s.label }}</label><br/>
                        <div class="make-switch switch-small">
                        {{ form.%s }}
                        </div>
                    </div>
                </div>
                """ % (
                i,
                i,
                i,
            )
        boolean_fields_html += """</div></div>"""

        self.helper.layout = Layout(
            Div(
                Div("name", css_class=css_class),
                Div("strategy", css_class=css_class),
                Div("moh_sound", css_class=css_class),
                Div("record_template", css_class=css_class),
                Div("time_base_score", css_class=css_class),
                Div("tier_rule_wait_second", css_class=css_class),
                Div("discard_abandoned_after", css_class=css_class),
                Div("max_wait_time", css_class=css_class),
                Div("max_wait_time_with_no_agent", css_class=css_class),
                Div("max_wait_time_with_no_agent_time_reached", css_class=css_class),
                HTML(boolean_fields_html),
                css_class="row",
            )
        )
        if self.instance.id:
            common_submit_buttons(self.helper.layout, default_action="update")
        else:
            common_submit_buttons(self.helper.layout, default_action="add")
Пример #29
0
 def __init__(self, *args, **kwargs):
     super(ConcurrentCallForm, self).__init__(*args, **kwargs)
     self.fields['from_date'].label = _('select date').capitalize()
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('switch_id', css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
Пример #30
0
 def __init__(self, user, *args, **kwargs):
     super(SMSSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(Div('from_date', css_class=css_class),
             Div('to_date', css_class=css_class),
             Div('status', css_class=css_class),
             Div('smscampaign', css_class=css_class),
             css_class='row'), )
     common_submit_buttons(self.helper.layout, 'search')
     if user:
         self.fields['smscampaign'].choices = get_smscampaign_list(user)
Пример #31
0
 def __init__(self, *args, **kwargs):
     super(BillingReportForm, self).__init__(*args, **kwargs)
     self.fields['switch_id'].choices = sw_list_with_all()
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('to_date', css_class=css_class),
             Div('switch_id', css_class=css_class),
             css_class='row',
         ), )
     common_submit_buttons(self.helper.layout, 'search')
Пример #32
0
    def __init__(self, user, *args, **kwargs):
        super(Contact_fileImport, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(
                Div(Fieldset('', 'phonebook', 'csv_file')),
            ),
        )
        common_submit_buttons(self.helper.layout, 'import')

        # To get user's phonebook list
        if user:  # and not user.is_superuser
            self.fields['phonebook'].choices = get_phonebook_list(user)
Пример #33
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContact_fileImport, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(
                Div(Fieldset('', 'dnc_list', 'csv_file',
                             css_class='col-md-6')), ), )
        common_submit_buttons(self.helper.layout, 'import')

        # To get user's dnc_list list
        # and not user.is_superuser
        if user:
            self.fields['dnc_list'].choices = get_dnc_list(user)
            self.fields['csv_file'].label = _('Upload CSV file')
Пример #34
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContactForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Div(Fieldset('', 'dnc', 'phone_number',
                             css_class='col-md-6')), ), )
        if user:
            self.fields['dnc'].choices = DNC.objects.values_list(
                'id', 'name').filter(user=user).order_by('id')

        if self.instance.id:
            common_submit_buttons(self.helper.layout, 'update')
        else:
            common_submit_buttons(self.helper.layout)
Пример #35
0
 def __init__(self, manager_id, *args, **kwargs):
     super(TierFrontEndForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     self.helper.layout = Layout(
         Div(
             Div(Fieldset('', 'agent', 'queue', 'level', 'position', css_class='col-md-6')),
         ),
     )
     if self.instance.id:
         common_submit_buttons(self.helper.layout, 'update')
     else:
         common_submit_buttons(self.helper.layout)
     self.fields['agent'].choices = agentprofile_list(manager_id)
     self.fields['queue'].choices = queue_list(manager_id)
Пример #36
0
 def __init__(self, user, *args, **kwargs):
     super(SMSCampaignSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-3'
     self.helper.layout = Layout(
         Div(
             Div('phonebook_id', css_class=css_class),
             Div('status', css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
     if user:
         self.fields['phonebook_id'].choices = get_phonebook_list(user)
Пример #37
0
 def __init__(self, *args, **kwargs):
     super(BillingReportForm, self).__init__(*args, **kwargs)
     self.fields['switch_id'].choices = sw_list_with_all()
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('to_date', css_class=css_class),
             Div('switch_id', css_class=css_class),
             css_class='row',
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
Пример #38
0
    def __init__(self, *args, **kwargs):
        super(CdrSearchForm, self).__init__(*args, **kwargs)
        self.fields['records_per_page'].widget.attrs['onchange'] = 'this.form.submit();'
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.form_class = 'well'
        self.helper.form_id = 'search-form-page'
        css_class = 'col-md-4'
        self.fields['result'].initial = 1

        self.helper.layout = Layout(
            Div(
                Div('from_date', css_class=css_class),
                Div('to_date', css_class=css_class),
                Div('switch_id', css_class=css_class),
                css_class='row'
            ),
            Div(
                Div('destination', css_class='col-md-2'),
                Div('destination_type', css_class='col-md-2'),
                Div('accountcode', css_class='col-md-4'),
                Div('caller_id_number', css_class='col-md-2'),
                Div('caller_id_number_type', css_class='col-md-2'),
                css_class='row'
            ),
            Div(
                Div('direction', css_class=css_class),
                Div('duration', css_class='col-md-3'),
                Div('duration_type', css_class='col-md-1'),
                Div(HTML("""
                    <b>Result : </b><br/>
                    <div class="btn-group" data-toggle="buttons">
                        {% for choice in form.result.field.choices %}
                        <label class="btn btn-default {% if choice.0 == form.result.value %}active{% endif %}">
                            <input name='{{ form.result.name }}' type='radio' value='{{ choice.0 }}'/> {{ choice.1 }}
                        </label>
                        {% endfor %}
                    </div>
                   """), css_class=css_class),
                css_class='row'
            ),
            Div(
                Div('country_id', css_class=css_class),
                css_class='row'
            ),
        )
        common_submit_buttons(self.helper.layout, 'search')
        self.fields['records_per_page'].widget.attrs['class'] = 'select form-control'
Пример #39
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContact_fileImport, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(
                Div(Fieldset('', 'dnc_list', 'csv_file', css_class='col-md-6')),
            ),
        )
        common_submit_buttons(self.helper.layout, 'import')

        # To get user's dnc_list list
        # and not user.is_superuser
        if user:
            self.fields['dnc_list'].choices = get_dnc_list(user)
            self.fields['csv_file'].label = _('Upload CSV file')
Пример #40
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContactForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(
                Div(Fieldset('', 'dnc', 'phone_number', css_class='col-md-6')),
            ),
        )
        if user:
            self.fields['dnc'].choices = DNC.objects.values_list('id', 'name').filter(user=user).order_by('id')

        if self.instance.id:
            common_submit_buttons(self.helper.layout, 'update')
        else:
            common_submit_buttons(self.helper.layout)
Пример #41
0
 def __init__(self, user, *args, **kwargs):
     super(EventSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(Div('start_date', css_class=css_class),
             Div('calendar_id', css_class=css_class),
             Div('calendar_user_id', css_class=css_class),
             css_class='row'), )
     common_submit_buttons(self.helper.layout, 'search')
     calendar_user_list = get_calendar_user_id_list(user)
     self.fields['calendar_id'].choices = get_calendar_list(
         calendar_user_list)
     self.fields['calendar_user_id'].choices = get_calendar_user_list(
         calendar_user_list)
Пример #42
0
    def __init__(self, user, *args, **kwargs):
        super(ContactForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()

        if self.instance.id:
            form_action = common_submit_buttons(default_action='update')
        else:
            form_action = common_submit_buttons(default_action='add')
        css_class = 'col-md-6'
        self.helper.layout = Layout(
            TabHolder(
                Tab(
                    _('General'),
                    Div(
                        Div('phonebook', css_class=css_class),
                        Div('contact', css_class=css_class),
                        Div('last_name', css_class=css_class),
                        Div('first_name', css_class=css_class),
                        Div('status', css_class=css_class),
                        Div('email', css_class=css_class),
                        css_class='row'
                    ),
                    form_action,
                    css_class='well'
                ),
                Tab(
                    _('Advanced Data'),
                    Div(
                        Div('unit_number', css_class=css_class),
                        Div('address', css_class=css_class),
                        Div('city', css_class=css_class),
                        Div('state', css_class=css_class),
                        Div('country', css_class=css_class),
                        Div('description', css_class=css_class),
                        Div('additional_vars', css_class=css_class),
                        css_class='row'
                    ),
                    form_action,
                    css_class='well'
                ),
            ),
        )

        # To get user's phonebook list
        if user:
            self.fields['phonebook'].choices = phonebook_list(user)
Пример #43
0
 def __init__(self, user, *args, **kwargs):
     super(EventSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('start_date', css_class=css_class),
             Div('calendar_id', css_class=css_class),
             Div('calendar_user_id', css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
     calendar_user_list = get_calendar_user_id_list(user)
     self.fields['calendar_id'].choices = get_calendar_list(calendar_user_list)
     self.fields['calendar_user_id'].choices = get_calendar_user_list(calendar_user_list)
Пример #44
0
 def __init__(self, user, *args, **kwargs):
     super(SMSSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = "well"
     css_class = "col-md-4"
     self.helper.layout = Layout(
         Div(
             Div("from_date", css_class=css_class),
             Div("to_date", css_class=css_class),
             Div("status", css_class=css_class),
             Div("smscampaign", css_class=css_class),
             css_class="row",
         )
     )
     common_submit_buttons(self.helper.layout, "search")
     if user:
         self.fields["smscampaign"].choices = get_smscampaign_list(user)
Пример #45
0
 def __init__(self, user, *args, **kwargs):
     super(SMSSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-4'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('to_date', css_class=css_class),
             Div('status', css_class=css_class),
             Div('smscampaign', css_class=css_class),
             css_class='row'
         ),
     )
     common_submit_buttons(self.helper.layout, 'search')
     if user:
         self.fields['smscampaign'].choices = get_smscampaign_list(user)
Пример #46
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContactSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(Div('phone_number', css_class='col-md-4'),
                Div('dnc', css_class='col-md-4'),
                css_class='row'), )
        common_submit_buttons(self.helper.layout, 'search')
        # To get user's dnc list
        if user:
            dnc_list_user = []
            dnc_list_user.append((0, '---'))
            for i in DNC.objects.values_list(
                    'id', 'name').filter(user=user).order_by('-id'):
                dnc_list_user.append((i[0], i[1]))

            self.fields['dnc'].choices = dnc_list_user
Пример #47
0
    def __init__(self, user, *args, **kwargs):
        super(SimulatorForm, self).__init__(*args, **kwargs)
        self.fields['plan_id'].choices = voip_plan_list()

        self.fields.keyOrder = ['plan_id', 'destination_no', ]
        if not user.is_superuser:
            self.fields['plan_id'] = forms.ChoiceField(widget=forms.HiddenInput())
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-4'
        self.helper.layout = Layout(
            Div(
                Div('destination_no', css_class=css_class),
                Div('plan_id', css_class=css_class),
                css_class='row',
            ),
        )
        common_submit_buttons(self.helper.layout, 'search')
Пример #48
0
 def __init__(self, manager_id, *args, **kwargs):
     super(TierFrontEndForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     self.helper.layout = Layout(
         Div(
             Div(
                 Fieldset('',
                          'agent',
                          'queue',
                          'level',
                          'position',
                          css_class='col-md-6')), ), )
     if self.instance.id:
         common_submit_buttons(self.helper.layout, 'update')
     else:
         common_submit_buttons(self.helper.layout)
     self.fields['agent'].choices = agentprofile_list(manager_id)
     self.fields['queue'].choices = queue_list(manager_id)
Пример #49
0
    def __init__(self, user, *args, **kwargs):
        super(AlarmReportForm, self).__init__(*args, **kwargs)
        alarm_list_user = []
        alarm_list_user.append((0, '---'))
        for i in Alarm.objects.values_list('id', 'name').filter(user=user).order_by('id'):
            alarm_list_user.append((i[0], i[1]))

        self.fields['alarm_id'].choices = alarm_list_user
        self.helper = FormHelper()
        self.helper.form_action = '.'
        self.helper.form_class = 'well'
        css_class = 'col-md-4'
        self.helper.layout = Layout(
            Div(
                Div('alarm_id', css_class=css_class),
                css_class='row',
            ),
        )
        common_submit_buttons(self.helper.layout, 'search')
Пример #50
0
    def __init__(self, user, *args, **kwargs):
        super(AlarmReportForm, self).__init__(*args, **kwargs)
        alarm_list_user = []
        alarm_list_user.append((0, '---'))
        for i in Alarm.objects.values_list(
                'id', 'name').filter(user=user).order_by('id'):
            alarm_list_user.append((i[0], i[1]))

        self.fields['alarm_id'].choices = alarm_list_user
        self.helper = FormHelper()
        self.helper.form_action = '.'
        self.helper.form_class = 'well'
        css_class = 'col-md-4'
        self.helper.layout = Layout(
            Div(
                Div('alarm_id', css_class=css_class),
                css_class='row',
            ), )
        common_submit_buttons(self.helper.layout, 'search')
Пример #51
0
    def __init__(self, *args, **kwargs):
        super(CdrSearchForm, self).__init__(*args, **kwargs)
        self.fields['records_per_page'].widget.attrs[
            'onchange'] = 'this.form.submit();'
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.form_class = 'well'
        self.helper.form_id = 'search-form-page'
        css_class = 'col-md-4'
        self.fields['result'].initial = 1

        self.helper.layout = Layout(
            Div(Div('from_date', css_class=css_class),
                Div('to_date', css_class=css_class),
                Div('switch_id', css_class=css_class),
                css_class='row'),
            Div(Div('destination', css_class='col-md-2'),
                Div('destination_type', css_class='col-md-2'),
                Div('accountcode', css_class='col-md-4'),
                Div('caller_id_number', css_class='col-md-2'),
                Div('caller_id_number_type', css_class='col-md-2'),
                css_class='row'),
            Div(Div('direction', css_class=css_class),
                Div('duration', css_class='col-md-3'),
                Div('duration_type', css_class='col-md-1'),
                Div(HTML("""
                    <b>Result : </b><br/>
                    <div class="btn-group" data-toggle="buttons">
                        {% for choice in form.result.field.choices %}
                        <label class="btn btn-default {% if choice.0 == form.result.value %}active{% endif %}">
                            <input name='{{ form.result.name }}' type='radio' value='{{ choice.0 }}'/> {{ choice.1 }}
                        </label>
                        {% endfor %}
                    </div>
                   """),
                    css_class=css_class),
                css_class='row'),
            Div(Div('country_id', css_class=css_class),
                Div('records_per_page', css_class=css_class),
                css_class='row'),
        )
        common_submit_buttons(self.helper.layout, 'search')
Пример #52
0
    def __init__(self, *args, **kwargs):
        super(QueueFrontEndForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        css_class = 'col-md-6'
        self.helper.form_class = 'well'
        boolean_fields = [
            'tier_rules_apply', 'tier_rule_wait_multiply_level',
            'tier_rule_no_agent_no_wait', 'abandoned_resume_allowed'
        ]
        boolean_fields_html = """<div class="row"><div class="col-md-12 col-xs-10">"""

        for i in boolean_fields:
            boolean_fields_html += """
                <div class="col-xs-6">
                    <div class="btn-group" data-toggle="buttons">
                        <label for="{{ form.%s.auto_id }}">{{ form.%s.label }}</label><br/>
                        <div class="make-switch switch-small">
                        {{ form.%s }}
                        </div>
                    </div>
                </div>
                """ % (i, i, i)
        boolean_fields_html += """</div></div>"""

        self.helper.layout = Layout(
            Div(Div('name', css_class=css_class),
                Div('strategy', css_class=css_class),
                Div('moh_sound', css_class=css_class),
                Div('record_template', css_class=css_class),
                Div('time_base_score', css_class=css_class),
                Div('tier_rule_wait_second', css_class=css_class),
                Div('discard_abandoned_after', css_class=css_class),
                Div('max_wait_time', css_class=css_class),
                Div('max_wait_time_with_no_agent', css_class=css_class),
                Div('max_wait_time_with_no_agent_time_reached',
                    css_class=css_class),
                HTML(boolean_fields_html),
                css_class='row'), )
        if self.instance.id:
            common_submit_buttons(self.helper.layout, default_action='update')
        else:
            common_submit_buttons(self.helper.layout, default_action='add')
Пример #53
0
    def __init__(self, *args, **kwargs):
        super(QueueFrontEndForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        css_class = 'col-md-6'
        self.helper.form_class = 'well'
        boolean_fields = ['tier_rules_apply', 'tier_rule_wait_multiply_level',
                          'tier_rule_no_agent_no_wait', 'abandoned_resume_allowed']
        boolean_fields_html = """<div class="row"><div class="col-md-12 col-xs-10">"""

        for i in boolean_fields:
            boolean_fields_html += """
                <div class="col-xs-6">
                    <div class="btn-group" data-toggle="buttons">
                        <label for="{{ form.%s.auto_id }}">{{ form.%s.label }}</label><br/>
                        <div class="make-switch switch-small">
                        {{ form.%s }}
                        </div>
                    </div>
                </div>
                """ % (i, i, i)
        boolean_fields_html += """</div></div>"""

        self.helper.layout = Layout(
            Div(
                Div('name', css_class=css_class),
                Div('strategy', css_class=css_class),
                Div('moh_sound', css_class=css_class),
                Div('record_template', css_class=css_class),
                Div('time_base_score', css_class=css_class),
                Div('tier_rule_wait_second', css_class=css_class),
                Div('discard_abandoned_after', css_class=css_class),
                Div('max_wait_time', css_class=css_class),
                Div('max_wait_time_with_no_agent', css_class=css_class),
                Div('max_wait_time_with_no_agent_time_reached', css_class=css_class),
                HTML(boolean_fields_html),
                css_class='row'
            ),
        )
        if self.instance.id:
            common_submit_buttons(self.helper.layout, default_action='update')
        else:
            common_submit_buttons(self.helper.layout, default_action='add')
Пример #54
0
    def __init__(self, user, *args, **kwargs):
        super(DNCContactSearchForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        self.helper.layout = Layout(
            Div(
                Div('phone_number', css_class='col-md-4'),
                Div('dnc', css_class='col-md-4'),
                css_class='row'
            ),
        )
        common_submit_buttons(self.helper.layout, 'search')
        # To get user's dnc list
        if user:
            dnc_list_user = []
            dnc_list_user.append((0, '---'))
            for i in DNC.objects.values_list('id', 'name').filter(user=user).order_by('-id'):
                dnc_list_user.append((i[0], i[1]))

            self.fields['dnc'].choices = dnc_list_user
Пример #55
0
    def __init__(self, user, *args, **kwargs):
        super(SimulatorForm, self).__init__(*args, **kwargs)
        self.fields['plan_id'].choices = voip_plan_list()

        self.fields.keyOrder = [
            'plan_id',
            'destination_no',
        ]
        if not user.is_superuser:
            self.fields['plan_id'] = forms.ChoiceField(
                widget=forms.HiddenInput())
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-4'
        self.helper.layout = Layout(
            Div(
                Div('destination_no', css_class=css_class),
                Div('plan_id', css_class=css_class),
                css_class='row',
            ), )
        common_submit_buttons(self.helper.layout, 'search')
Пример #56
0
    def __init__(self, user, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_class = 'well'
        css_class = 'col-md-3'
        self.helper.layout = Layout(
            Div(Div('from_date', css_class=css_class),
                Div('to_date', css_class=css_class),
                Div('campaign_id', css_class=css_class),
                Div('status', css_class=css_class),
                css_class='row'), )
        common_submit_buttons(self.helper.layout, 'search')
        super(SubscriberSearchForm, self).__init__(*args, **kwargs)
        if user:
            camp_list = []
            camp_list.append((0, _('all').upper()))
            if user.is_superuser:
                campaign_list = Campaign.objects.values_list(
                    'id', 'name').all().order_by('-id')
            else:
                campaign_list = Campaign.objects.values_list(
                    'id', 'name').filter(user=user).order_by('-id')

            for i in campaign_list:
                camp_list.append((i[0], i[1]))
            """
            agent_list = []
            agent_list.append((0, _('all').upper()))
            if user.is_superuser:
                agent_profile_list = AgentProfile.objects.values_list('user_id', flat=True).filter(is_agent=True)
            else:
                agent_profile_list = AgentProfile.objects.values_list('user_id', flat=True)\
                    .filter(is_agent=True, manager=user)

            a_list = Agent.objects.values_list('id', 'username').filter(id__in=agent_profile_list)
            for i in a_list:
                agent_list.append((i[0], i[1]))
            self.fields['agent_id'].choices = agent_list
            """
            self.fields['campaign_id'].choices = camp_list
Пример #57
0
    def __init__(self, user, *args, **kwargs):
        super(ContactForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()

        if self.instance.id:
            form_action = common_submit_buttons(default_action='update')
        else:
            form_action = common_submit_buttons(default_action='add')
        css_class = 'col-md-6'
        self.helper.layout = Layout(
            TabHolder(
                Tab(_('general').capitalize(),
                    Div(Div('phonebook', css_class=css_class),
                        Div('contact', css_class=css_class),
                        Div('last_name', css_class=css_class),
                        Div('first_name', css_class=css_class),
                        Div('status', css_class=css_class),
                        Div('email', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
                Tab(_('advanced data').capitalize(),
                    Div(Div('unit_number', css_class=css_class),
                        Div('address', css_class=css_class),
                        Div('city', css_class=css_class),
                        Div('state', css_class=css_class),
                        Div('country', css_class=css_class),
                        Div('description', css_class=css_class),
                        Div('additional_vars', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
            ), )

        # To get user's phonebook list
        if user:
            self.fields['phonebook'].choices = phonebook_list(user)
Пример #58
0
 def __init__(self, *args, **kwargs):
     super(CompareCallSearchForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'well'
     css_class = 'col-md-3'
     self.helper.layout = Layout(
         Div(
             Div('from_date', css_class=css_class),
             Div('compare_days', css_class=css_class),
             Div('switch_id', css_class=css_class),
             Div('metric', css_class=css_class),
             # Div(HTML("""
             #     <b>Check with* : </b><br/>
             #     <div class="btn-group" data-toggle="buttons">
             #         {% for choice in form.compare_type.field.choices %}
             #         <label class="btn btn-default">
             #             <input name='{{ form.compare_type.name }}' type='radio' value='{{ choice.0 }}'/>
             #             {{ choice.1 }}
             #         </label>
             #         {% endfor %}
             #     </div>
             #    """), css_class=css_class),
             css_class='row'), )
     common_submit_buttons(self.helper.layout, 'search')
Пример #59
0
    def __init__(self, user, *args, **kwargs):
        super(CampaignForm, self).__init__(*args, **kwargs)
        self.user = user
        self.helper = FormHelper()
        if self.instance.id:
            form_action = common_submit_buttons(default_action='update')
        else:
            form_action = common_submit_buttons(default_action='add')

        week_days = [
            'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
            'sunday'
        ]
        week_days_html = """<div class="row"><div class="col-md-12 col-xs-6">"""

        for i in week_days:
            week_days_html += """
                <div class="col-md-3">
                    <div class="btn-group" data-toggle="buttons">
                        <label for="{{ form.%s.auto_id }}">{{ form.%s.label }}</label><br/>
                        <div class="make-switch switch-small">
                        {{ form.%s }}
                        </div>
                    </div>
                </div>
                """ % (i, i, i)
        week_days_html += """</div></div>"""
        css_class = 'col-md-6'

        self.helper.layout = Layout(
            Field('campaign_code'),
            TabHolder(
                Tab(_('general').title(),
                    Div(Div(Fieldset(_('general settings').title()),
                            css_class='col-md-12'),
                        Div('name', css_class=css_class),
                        Div('callerid', css_class=css_class),
                        Div('caller_name', css_class=css_class),
                        Div('content_object', css_class=css_class),
                        css_class='row'),
                    Div(Div('extra_data', css_class=css_class),
                        Div('dnc', css_class=css_class),
                        Div('description', css_class=css_class),
                        Div('phonebook', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
                Tab('Dialer',
                    Div(Div(Fieldset(_('dialer settings').title()),
                            css_class='col-md-12'),
                        Div('aleg_gateway', css_class=css_class),
                        Div('frequency', css_class=css_class),
                        Div('callmaxduration', css_class=css_class),
                        Div('maxretry', css_class=css_class),
                        Div('intervalretry', css_class=css_class),
                        Div('calltimeout', css_class=css_class),
                        Div(Fieldset(_('dialer completion settings').title()),
                            css_class='col-md-12'),
                        Div('completion_maxretry', css_class=css_class),
                        Div('completion_intervalretry', css_class=css_class),
                        Div('sms_gateway', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
                Tab('schedule',
                    Div(Div(Fieldset(_('schedule settings').title()),
                            css_class='col-md-12'),
                        Div(HTML("""<label>%s<label>""" %
                                 (_('week days').capitalize())),
                            css_class="col-md-3"),
                        HTML(week_days_html),
                        HTML("""<div>&nbsp;</div>"""),
                        Div('startingdate', css_class=css_class),
                        Div('expirationdate', css_class=css_class),
                        Div('daily_start_time', css_class=css_class),
                        Div('daily_stop_time', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
            ),
        )

        if settings.AMD:
            amd_layot = Tab(_('voicemail').capitalize(),
                            Div(Div(Fieldset(_('voicemail settings').title()),
                                    css_class='col-md-12'),
                                Div(HTML("""
                                    <div class="btn-group" data-toggle="buttons">
                                        <label for="{{ form.voicemail.auto_id }}">{{ form.voicemail.label }}</label>
                                        <br/>
                                        <div class="make-switch switch-small">
                                        {{ form.voicemail }}
                                        </div>
                                    </div>
                                    """),
                                    css_class='col-md-12 col-xs-10'),
                                HTML("""<div>&nbsp;</div>"""),
                                Div('amd_behavior', css_class=css_class),
                                Div('voicemail_audiofile',
                                    css_class=css_class),
                                css_class='row'),
                            form_action,
                            css_class='well')
            self.helper.layout[1].insert(2, amd_layot)
        # hidden var
        self.helper.layout.append(Field('selected_phonebook'))
        self.helper.layout.append(Field('selected_content_object'))

        instance = getattr(self, 'instance', None)
        self.fields['campaign_code'].initial = get_unique_code(length=5)

        if user:
            list_gw = []
            dnc_list = []
            phonebook_list = get_phonebook_list(user)
            if not phonebook_list:
                phonebook_list = []
                phonebook_list.append(('', '---'))

            self.fields['phonebook'].choices = phonebook_list
            self.fields['phonebook'].initial = str(phonebook_list[0][0])

            gateway_list = UserProfile.objects.get(
                user=user).userprofile_gateway.all()
            gw_list = ((l.id, l.name) for l in gateway_list)

            dnc_list.append(('', '---'))
            dnc_obj_list = DNC.objects.values_list(
                'id', 'name').filter(user=user).order_by('id')
            for l in dnc_obj_list:
                dnc_list.append((l[0], l[1]))
            self.fields['dnc'].choices = dnc_list

            for i in gw_list:
                list_gw.append((i[0], i[1]))
            self.fields['aleg_gateway'].choices = UserProfile.objects.get(user=user)\
                .userprofile_gateway.all().values_list('id', 'name')

            if instance.has_been_duplicated:
                from survey.models import Survey
                available_objects = Survey.objects.filter(user=user,
                                                          campaign=instance)
                object_choices = get_object_choices(available_objects)
                self.fields['content_object'].widget.attrs['readonly'] = True
            else:
                from survey.models import Survey_template
                available_objects = Survey_template.objects.filter(user=user)
                object_choices = get_object_choices(available_objects)

            self.fields['content_object'].choices = object_choices

            # Voicemail setting is not enabled by default
            if settings.AMD:
                from survey.forms import get_audiofile_list
                self.fields[
                    'voicemail_audiofile'].choices = get_audiofile_list(user)

        # If campaign is running or has been started
        if instance.status == CAMPAIGN_STATUS.START or instance.has_been_started:
            self.fields['name'].widget.attrs['readonly'] = True
            self.fields['caller_name'].widget.attrs['readonly'] = True
            self.fields['callerid'].widget.attrs['readonly'] = True
            self.fields['extra_data'].widget.attrs['readonly'] = True
            self.fields['phonebook'].widget.attrs['readonly'] = True
            self.fields['lead_disposition'].widget.attrs['readonly'] = True
            self.fields['dnc'].widget.attrs['readonly'] = True
            self.fields['aleg_gateway'].widget.attrs['readonly'] = True
            self.fields['sms_gateway'].widget.attrs['readonly'] = True
            self.fields['voicemail'].widget.attrs['readonly'] = True
            self.fields['amd_behavior'].widget.attrs['readonly'] = True
            self.fields['voicemail_audiofile'].widget.attrs['readonly'] = True

            selected_phonebook = ''
            if instance.phonebook.all():
                selected_phonebook = ",".join(
                    ["%s" % (i.id) for i in instance.phonebook.all()])
            self.fields['selected_phonebook'].initial = selected_phonebook

            self.fields['content_object'].widget.attrs['disabled'] = 'disabled'
            self.fields['content_object'].required = False
            self.fields['selected_content_object'].initial = "type:%s-id:%s" % \
                (instance.content_type.id, instance.object_id)
Пример #60
0
    def __init__(self, user, *args, **kwargs):
        super(SMSCampaignForm, self).__init__(*args, **kwargs)
        self.user = user
        self.helper = FormHelper()

        if self.instance.id:
            form_action = common_submit_buttons(default_action='update')
        else:
            form_action = common_submit_buttons(default_action='add')

        week_days = [
            'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
            'sunday'
        ]
        week_days_html = """<div class="row"><div class="col-md-12 col-xs-6">"""

        for i in week_days:
            week_days_html += """
                <div class="col-md-3">
                    <div class="btn-group" data-toggle="buttons">
                        <label for="{{ form.%s.auto_id }}">{{ form.%s.label }}</label><br/>
                        <div class="make-switch switch-small">
                        {{ form.%s }}
                        </div>
                    </div>
                </div>
                """ % (i, i, i)

        week_days_html += """</div></div>"""
        css_class = 'col-md-6'
        self.helper.layout = Layout(
            Field('campaign_code'),
            TabHolder(
                Tab(_('general settings').title(),
                    Div(Div('name', css_class=css_class),
                        Div('callerid', css_class=css_class),
                        Div('sms_gateway', css_class=css_class),
                        Div('phonebook', css_class=css_class),
                        Div('extra_data', css_class=css_class),
                        Div('text_message', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
                Tab(_('completion settings').title(),
                    Div(Div('frequency', css_class=css_class),
                        Div('maxretry', css_class=css_class),
                        Div('intervalretry', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
                Tab('schedule',
                    Div(Div(HTML("""<label>%s<label>""" %
                                 (_('week days').capitalize())),
                            css_class="col-md-3"),
                        HTML(week_days_html),
                        HTML("""<div>&nbsp;</div>"""),
                        Div('startingdate', css_class=css_class),
                        Div('expirationdate', css_class=css_class),
                        Div('daily_start_time', css_class=css_class),
                        Div('daily_stop_time', css_class=css_class),
                        css_class='row'),
                    form_action,
                    css_class='well'),
            ),
        )

        self.fields['campaign_code'].initial = get_unique_code(length=5)
        if user:
            phonebook_list = get_phonebook_list(user)
            self.fields['phonebook'].choices = phonebook_list
            self.fields['phonebook'].initial = str(phonebook_list[0][0])