Example #1
0
    def __init__(self, *args, **kwargs):
        domain = kwargs.pop('domain', None)
        self.can_use_custom_logo = kwargs.pop('can_use_custom_logo', False)
        super(DomainGlobalSettingsForm, self).__init__(*args, **kwargs)
        if not self.can_use_custom_logo:
            del self.fields['logo']
            del self.fields['delete_logo']

        if domain:
            if not CALLCENTER.enabled(domain):
                self.fields['call_center_enabled'].widget = forms.HiddenInput()
                self.fields['call_center_case_owner'].widget = forms.HiddenInput()
                self.fields['call_center_case_type'].widget = forms.HiddenInput()
            else:
                groups = Group.get_case_sharing_groups(domain)
                users = CommCareUser.by_domain(domain)

                call_center_user_choices = [
                    (user._id, user.raw_username + ' [user]') for user in users
                ]
                call_center_group_choices = [
                    (group._id, group.name + ' [group]') for group in groups
                ]

                self.fields["call_center_case_owner"].choices = \
                    [('', '')] + \
                    call_center_user_choices + \
                    call_center_group_choices
Example #2
0
    def case_properties(self):
        props = set([])

        if CALLCENTER.enabled(self.domain):
            from corehq.apps.custom_data_fields.models import CustomDataFieldsDefinition
            user_fields = CustomDataFieldsDefinition.get_or_create(self.domain, 'UserFields')
            props |= {field.slug for field in user_fields.fields}

        for app in self.applications:
            builder = ParentCasePropertyBuilder(app, ("name",))
            props |= set(builder.get_properties(self.case_type))

        return props
Example #3
0
    def __init__(self, *args, **kwargs):
        user = kwargs.pop('user', None)
        domain = kwargs.pop('domain', None)
        super(DomainMetadataForm, self).__init__(*args, **kwargs)

        if not CALLCENTER.enabled(domain):
            self.fields['call_center_enabled'].widget = forms.HiddenInput()
            self.fields['call_center_case_owner'].widget = forms.HiddenInput()
            self.fields['call_center_case_type'].widget = forms.HiddenInput()

        if not (user and user.is_staff):
            self.fields['restrict_superusers'].widget = forms.HiddenInput()

        project = Domain.get_by_name(domain)
        if project.cloudcare_releases == 'default' or not domain_has_privilege(domain, privileges.CLOUDCARE):
            # if the cloudcare_releases flag was just defaulted, don't bother showing
            # this setting at all
            self.fields['cloudcare_releases'].widget = forms.HiddenInput()

        if domain is not None:
            groups = Group.get_case_sharing_groups(domain)
            users = CommCareUser.by_domain(domain)

            domain_group_choices = [(group._id, group.name) for group in groups]
            domain_user_choices = [(user._id, user.raw_username) for user in users]
            domain_owner_choices = domain_group_choices + domain_user_choices

            self.fields["sms_case_registration_owner_id"].choices = domain_owner_choices
            self.fields["sms_case_registration_user_id"].choices = domain_user_choices

            call_center_user_choices = [(user._id, user.raw_username + ' [user]')
                                         for user in users]
            call_center_group_choices = [(group._id, group.name + ' [group]')
                                         for group in groups]

            self.fields["call_center_case_owner"].choices = \
                [('', '')] + \
                call_center_user_choices + \
                call_center_group_choices
Example #4
0
def get_call_center_case_type_if_enabled(domain):
    if CALLCENTER.enabled(domain):
        return Domain.get_by_name(domain).call_center_config.case_type
Example #5
0
def get_call_center_case_type_if_enabled(domain):
    if CALLCENTER.enabled(domain):
        return Domain.get_by_name(domain).call_center_config.case_type