예제 #1
0
파일: views.py 프로젝트: tsinkala/core-hq
def internal_settings(request, domain, template='domain/internal_settings.html'):
    domain = Domain.get_by_name(domain)

    if request.method == 'POST':
        internal_form = DomainInternalForm(request.POST)
        if internal_form.is_valid():
            internal_form.save(domain)
            messages.success(request, "The internal information for project %s was successfully updated!" % domain.name)
        else:
            messages.error(request, "There seems to have been an error. Please try again!")
    else:
        internal_form = DomainInternalForm(initial={
            "sf_contract_id": domain.internal.sf_contract_id,
            "sf_account_id": domain.internal.sf_account_id,
            "commcare_edition": domain.internal.commcare_edition,
            "services": domain.internal.services,
            "real_space": 'true' if domain.internal.real_space else 'false',
            "initiative": domain.internal.initiative,
            "project_state": domain.internal.project_state,
            "self_started": 'true' if domain.internal.self_started else 'false',
            "area": domain.internal.area,
            "sub_area": domain.internal.sub_area,
            "using_adm": 'true' if domain.internal.using_adm else 'false',
            "using_call_center": 'true' if domain.internal.using_call_center else 'false',
            "custom_eula": 'true' if domain.internal.custom_eula else 'false',
            "can_use_data": 'true' if domain.internal.can_use_data else 'false',
            "organization_name": domain.internal.organization_name,
            "notes": domain.internal.notes,
        })

    return render(request, template, {"project": domain, "domain": domain.name, "form": internal_form, 'active': 'settings'})
예제 #2
0
 def internal_settings_form(self):
     can_edit_eula = toggles.CAN_EDIT_EULA.enabled(
         self.request.couch_user.username)
     if self.request.method == 'POST':
         return DomainInternalForm(self.request.domain, can_edit_eula,
                                   self.request.POST)
     initial = {
         'countries':
         self.domain_object.deployment.countries,
         'is_test':
         self.domain_object.is_test,
         'use_custom_auto_case_update_limit':
         'Y' if self.domain_object.auto_case_update_limit else 'N',
         'auto_case_update_limit':
         self.domain_object.auto_case_update_limit,
         'granted_messaging_access':
         self.domain_object.granted_messaging_access,
     }
     internal_attrs = [
         'sf_contract_id',
         'sf_account_id',
         'initiative',
         'self_started',
         'area',
         'sub_area',
         'organization_name',
         'notes',
         'phone_model',
         'commtrack_domain',
         'performance_threshold',
         'experienced_threshold',
         'amplifies_workers',
         'amplifies_project',
         'data_access_threshold',
         'business_unit',
         'workshop_region',
         'partner_technical_competency',
         'support_prioritization',
         'gs_continued_involvement',
         'technical_complexity',
         'app_design_comments',
         'training_materials',
         'partner_comments',
         'partner_contact',
         'dimagi_contact',
     ]
     if can_edit_eula:
         internal_attrs += [
             'custom_eula',
             'can_use_data',
         ]
     for attr in internal_attrs:
         val = getattr(self.domain_object.internal, attr)
         if isinstance(val, bool):
             val = 'true' if val else 'false'
         initial[attr] = val
     return DomainInternalForm(self.request.domain,
                               can_edit_eula,
                               initial=initial)
예제 #3
0
def internal_settings(request,
                      domain,
                      template='domain/internal_settings.html'):
    domain = Domain.get_by_name(domain)

    if request.method == 'POST':
        internal_form = DomainInternalForm(request.POST)
        if internal_form.is_valid():
            internal_form.save(domain)
            messages.success(
                request,
                "The internal information for project %s was successfully updated!"
                % domain.name)
        else:
            messages.error(
                request,
                "There seems to have been an error. Please try again!")
    else:
        internal_form = DomainInternalForm(
            initial={
                "sf_contract_id":
                domain.internal.sf_contract_id,
                "sf_account_id":
                domain.internal.sf_account_id,
                "commcare_edition":
                domain.internal.commcare_edition,
                "services":
                domain.internal.services,
                "initiative":
                domain.internal.initiative,
                "project_state":
                domain.internal.project_state,
                "self_started":
                'true' if domain.internal.self_started else 'false',
                "area":
                domain.internal.area,
                "sub_area":
                domain.internal.sub_area,
                "using_adm":
                'true' if domain.internal.using_adm else 'false',
                "using_call_center":
                'true' if domain.internal.using_call_center else 'false',
                "custom_eula":
                'true' if domain.internal.custom_eula else 'false',
                "can_use_data":
                'true' if domain.internal.can_use_data else 'false',
                "organization_name":
                domain.internal.organization_name,
                "notes":
                domain.internal.notes,
            })

    return render(
        request, template, {
            "project": domain,
            "domain": domain.name,
            "form": internal_form,
            'active': 'settings'
        })