예제 #1
0
 def save(self, request, domain):
     res = DomainGlobalSettingsForm.save(self, request, domain)
     if not res:
         return False
     try:
         domain.project_type = self.cleaned_data['project_type']
         domain.customer_type = self.cleaned_data['customer_type']
         domain.is_test = self.cleaned_data['is_test'] == 'true'
         domain.survey_management_enabled = self.cleaned_data.get('survey_management_enabled', False)
         domain.sms_case_registration_enabled = self.cleaned_data.get('sms_case_registration_enabled', False)
         domain.sms_case_registration_type = self.cleaned_data.get('sms_case_registration_type')
         domain.sms_case_registration_owner_id = self.cleaned_data.get('sms_case_registration_owner_id')
         domain.sms_case_registration_user_id = self.cleaned_data.get('sms_case_registration_user_id')
         domain.default_sms_backend_id = self.cleaned_data.get('default_sms_backend_id')
         domain.commtrack_enabled = self.cleaned_data.get('commtrack_enabled', False)
         domain.call_center_config.enabled = self.cleaned_data.get('call_center_enabled', False)
         if domain.call_center_config.enabled:
             domain.internal.using_call_center = True
             domain.call_center_config.case_owner_id = self.cleaned_data.get('call_center_case_owner', None)
             domain.call_center_config.case_type = self.cleaned_data.get('call_center_case_type', None)
         domain.restrict_superusers = self.cleaned_data.get('restrict_superusers', False)
         commtrack_util.bootstrap_default(domain)
         domain.save()
         return True
     except Exception:
         return False
예제 #2
0
 def save(self, request, domain):
     res = DomainGlobalSettingsForm.save(self, request, domain)
     if not res:
         return False
     try:
         domain.project_type = self.cleaned_data['project_type']
         domain.customer_type = self.cleaned_data['customer_type']
         domain.is_test = self.cleaned_data['is_test'] == 'true'
         domain.survey_management_enabled = self.cleaned_data.get(
             'survey_management_enabled', False)
         domain.sms_case_registration_enabled = self.cleaned_data.get(
             'sms_case_registration_enabled', False)
         domain.sms_case_registration_type = self.cleaned_data.get(
             'sms_case_registration_type')
         domain.sms_case_registration_owner_id = self.cleaned_data.get(
             'sms_case_registration_owner_id')
         domain.sms_case_registration_user_id = self.cleaned_data.get(
             'sms_case_registration_user_id')
         domain.default_sms_backend_id = self.cleaned_data.get(
             'default_sms_backend_id')
         domain.commtrack_enabled = self.cleaned_data.get(
             'commtrack_enabled', False)
         commtrack_util.bootstrap_default(domain)
         domain.save()
         return True
     except Exception:
         return False
예제 #3
0
파일: util.py 프로젝트: tsinkala/core-hq
def bootstrap_domain(domain_name=TEST_DOMAIN, requisitions_enabled=False):
    # little test utility that makes a commtrack-enabled domain with
    # a default config and a location
    domain_obj = create_domain(domain_name)
    domain_obj.commtrack_enabled = True
    domain_obj.save(**get_safe_write_kwargs())
    bootstrap_default(domain_name, requisitions_enabled)
    return domain_obj
예제 #4
0
def bootstrap_domain(domain_name=TEST_DOMAIN, requisitions_enabled=False):
    # little test utility that makes a commtrack-enabled domain with
    # a default config and a location
    domain_obj = create_domain(domain_name)
    domain_obj.commtrack_enabled = True
    domain_obj.save(**get_safe_write_kwargs())
    bootstrap_default(domain_obj, requisitions_enabled)

    return domain_obj
예제 #5
0
def request_new_domain(request, form, org, domain_type=None, new_user=True):
    now = datetime.utcnow()
    current_user = CouchUser.from_django_user(request.user)

    commtrack_enabled = domain_type == 'commtrack'

    dom_req = RegistrationRequest()
    if new_user:
        dom_req.request_time = now
        dom_req.request_ip = get_ip(request)
        dom_req.activation_guid = uuid.uuid1().hex

    new_domain = Domain(name=form.cleaned_data['domain_name'],
                        is_active=False,
                        date_created=datetime.utcnow(),
                        commtrack_enabled=commtrack_enabled,
                        creating_user=current_user.username)

    bootstrap_default(new_domain)

    if org:
        new_domain.organization = org
        new_domain.hr_name = request.POST.get('domain_hrname',
                                              None) or new_domain.name

    if not new_user:
        new_domain.is_active = True

    # ensure no duplicate domain documents get created on cloudant
    new_domain.save(**get_safe_write_kwargs())

    if not new_domain.name:
        new_domain.name = new_domain._id
        new_domain.save()  # we need to get the name from the _id

    dom_req.domain = new_domain.name

    if request.user.is_authenticated():
        if not current_user:
            current_user = WebUser()
            current_user.sync_from_django_user(request.user)
            current_user.save()
        current_user.add_domain_membership(new_domain.name, is_admin=True)
        current_user.save()
        dom_req.requesting_user_username = request.user.username
        dom_req.new_user_username = request.user.username

    if new_user:
        dom_req.save()
        send_domain_registration_email(request.user.email, dom_req.domain,
                                       dom_req.activation_guid)
    else:
        send_global_domain_registration_email(request.user, new_domain.name)
    send_new_domain_request_update_email(request.user,
                                         get_ip(request),
                                         new_domain.name,
                                         is_new_user=new_user)
예제 #6
0
def request_new_domain(request, form, org, domain_type=None, new_user=True):
    now = datetime.utcnow()
    current_user = CouchUser.from_django_user(request.user)

    commtrack_enabled = domain_type == 'commtrack'

    dom_req = RegistrationRequest()
    if new_user:
        dom_req.request_time = now
        dom_req.request_ip = get_ip(request)
        dom_req.activation_guid = uuid.uuid1().hex

    new_domain = Domain(name=form.cleaned_data['domain_name'],
        is_active=False,
        date_created=datetime.utcnow(),
        commtrack_enabled=commtrack_enabled,
        creating_user=current_user.username)

    bootstrap_default(new_domain)    

    if org:
        new_domain.organization = org
        new_domain.hr_name = request.POST.get('domain_hrname', None) or new_domain.name

    if not new_user:
        new_domain.is_active = True

    # ensure no duplicate domain documents get created on cloudant
    new_domain.save(**get_safe_write_kwargs())

    if not new_domain.name:
        new_domain.name = new_domain._id
        new_domain.save() # we need to get the name from the _id

    dom_req.domain = new_domain.name

    if request.user.is_authenticated():
        if not current_user:
            current_user = WebUser()
            current_user.sync_from_django_user(request.user)
            current_user.save()
        current_user.add_domain_membership(new_domain.name, is_admin=True)
        current_user.save()
        dom_req.requesting_user_username = request.user.username
        dom_req.new_user_username = request.user.username

    if new_user:
        dom_req.save()
        send_domain_registration_email(request.user.email,
                                       dom_req.domain,
                                       dom_req.activation_guid)
    else:
        send_global_domain_registration_email(request.user, new_domain.name)
    send_new_domain_request_update_email(request.user, get_ip(request), new_domain.name, is_new_user=new_user)
예제 #7
0
파일: forms.py 프로젝트: birdsarah/core-hq
 def save(self, request, domain):
     res = DomainGlobalSettingsForm.save(self, request, domain)
     if not res:
         return False
     try:
         domain.project_type = self.cleaned_data['project_type']
         domain.customer_type = self.cleaned_data['customer_type']
         domain.is_test = self.cleaned_data['is_test'] == 'true'
         domain.survey_management_enabled = self.cleaned_data.get('survey_management_enabled', False)
         domain.commtrack_enabled = self.cleaned_data.get('commtrack_enabled', False)
         if domain.commtrack_enabled and not domain.commtrack_settings:
             commtrack_util.bootstrap_default(domain.name)
         domain.save()
         return True
     except Exception:
         return False
예제 #8
0
파일: util.py 프로젝트: birdsarah/core-hq
def bootstrap_domain(domain_name=TEST_DOMAIN, requisitions_enabled=False):
    # little test utility that makes a commtrack-enabled domain with
    # a default config and a location
    domain_obj = create_domain(domain_name)
    domain_obj.commtrack_enabled = True
    domain_obj.save()
    config = bootstrap_default(domain_name)
    if requisitions_enabled:
        config.requisition_config.enabled = True
        config.save()
    return domain_obj