Esempio n. 1
0
 def page_context(self):
     context = {
         'are_groups':
         bool(len(self.all_groups)),
         'groups_url':
         reverse('all_groups', args=[self.domain]),
         'group_form':
         self.group_form,
         'reset_password_form':
         self.reset_password_form,
         'is_currently_logged_in_user':
         self.is_currently_logged_in_user,
         'data_fields_form':
         self.custom_data.form,
         'can_use_inbound_sms':
         domain_has_privilege(self.domain, privileges.INBOUND_SMS),
         'needs_to_downgrade_locations':
         (users_have_locations(self.domain)
          and not has_privilege(self.request, privileges.LOCATIONS)),
         'demo_restore_date':
         naturaltime(demo_restore_date_created(self.editable_user)),
         'hide_password_feedback':
         settings.ENABLE_DRACONIAN_SECURITY_FEATURES
     }
     if self.domain_object.commtrack_enabled or self.domain_object.uses_locations:
         context.update({
             'commtrack_enabled': self.domain_object.commtrack_enabled,
             'uses_locations': self.domain_object.uses_locations,
             'commtrack': {
                 'update_form': self.update_commtrack_form,
             },
         })
     return context
Esempio n. 2
0
 def page_context(self):
     from corehq.apps.users.views.mobile import GroupsListView
     context = {
         'are_groups': bool(len(self.all_groups)),
         'groups_url': reverse('all_groups', args=[self.domain]),
         'group_form': self.group_form,
         'reset_password_form': self.reset_password_form,
         'is_currently_logged_in_user': self.is_currently_logged_in_user,
         'data_fields_form': self.form_user_update.custom_data.form,
         'can_use_inbound_sms': domain_has_privilege(self.domain, privileges.INBOUND_SMS),
         'can_create_groups': (
             self.request.couch_user.has_permission(self.domain, 'edit_commcare_users') and
             self.request.couch_user.has_permission(self.domain, 'access_all_locations')
         ),
         'needs_to_downgrade_locations': (
             users_have_locations(self.domain) and
             not has_privilege(self.request, privileges.LOCATIONS)
         ),
         'demo_restore_date': naturaltime(demo_restore_date_created(self.editable_user)),
         'hide_password_feedback': settings.ENABLE_DRACONIAN_SECURITY_FEATURES
     }
     if self.commtrack_form.errors:
         messages.error(self.request, _(
             "There were some errors while saving user's locations. Please check the 'Locations' tab"
         ))
     if self.domain_object.commtrack_enabled or self.domain_object.uses_locations:
         context.update({
             'commtrack_enabled': self.domain_object.commtrack_enabled,
             'uses_locations': self.domain_object.uses_locations,
             'commtrack': {
                 'update_form': self.commtrack_form,
             },
         })
     return context
Esempio n. 3
0
 def page_context(self):
     context = {
         'are_groups': bool(len(self.all_groups)),
         'groups_url': reverse('all_groups', args=[self.domain]),
         'group_form': self.group_form,
         'reset_password_form': self.reset_password_form,
         'is_currently_logged_in_user': self.is_currently_logged_in_user,
         'data_fields_form': self.custom_data.form,
         'can_use_inbound_sms': domain_has_privilege(self.domain, privileges.INBOUND_SMS),
         'needs_to_downgrade_locations': (
             users_have_locations(self.domain) and
             not has_privilege(self.request, privileges.LOCATIONS)
         ),
         'demo_restore_date': naturaltime(demo_restore_date_created(self.editable_user)),
         'hide_password_feedback': settings.ENABLE_DRACONIAN_SECURITY_FEATURES
     }
     if self.commtrack_form.errors:
         messages.error(self.request, _(
             "There were some errors while saving user's locations. Please check the 'Locations' tab"
         ))
     if self.domain_object.commtrack_enabled or self.domain_object.uses_locations:
         context.update({
             'commtrack_enabled': self.domain_object.commtrack_enabled,
             'uses_locations': self.domain_object.uses_locations,
             'commtrack': {
                 'update_form': self.commtrack_form,
             },
         })
     return context
Esempio n. 4
0
 def main_context(self):
     context = super(BaseGroupsView, self).main_context
     context.update({
         'all_groups':
         self.all_groups,
         'needs_to_downgrade_locations':
         (users_have_locations(self.domain)
          and not has_privilege(self.request, privileges.LOCATIONS)),
     })
     return context
Esempio n. 5
0
 def main_context(self):
     context = super(BaseGroupsView, self).main_context
     context.update({
         'all_groups': self.all_groups,
         'needs_to_downgrade_locations': (
             users_have_locations(self.domain) and
             not has_privilege(self.request, privileges.LOCATIONS)
         ),
     })
     return context
Esempio n. 6
0
 def main_context(self):
     context = super(BaseGroupsView, self).main_context
     context.update({
         'all_groups':
         self.all_groups,
         'is_case_sharing_enabled':
         has_privilege(self.request, privileges.CASE_SHARING_GROUPS),
         'needs_to_downgrade_locations':
         (users_have_locations(self.domain)
          and not has_privilege(self.request, privileges.LOCATIONS)),
     })
     return context
Esempio n. 7
0
 def page_context(self):
     context = {
         'are_groups': bool(len(self.all_groups)),
         'groups_url': reverse('all_groups', args=[self.domain]),
         'group_form': self.group_form,
         'reset_password_form': self.reset_password_form,
         'is_currently_logged_in_user': self.is_currently_logged_in_user,
         'data_fields_form': self.custom_data.form,
         'can_use_inbound_sms': domain_has_privilege(self.domain, privileges.INBOUND_SMS),
         'needs_to_downgrade_locations': (
             users_have_locations(self.domain) and
             not has_privilege(self.request, privileges.LOCATIONS)
         ),
     }
     if self.domain_object.commtrack_enabled or self.domain_object.uses_locations:
         context.update({
             'commtrack_enabled': self.domain_object.commtrack_enabled,
             'uses_locations': self.domain_object.uses_locations,
             'commtrack': {
                 'update_form': self.update_commtrack_form,
             },
         })
     return context
Esempio n. 8
0
def calced_props(dom, id, all_stats):
    return {
        "_id": id,
        "cp_n_web_users": int(all_stats["web_users"].get(dom, 0)),
        "cp_n_active_cc_users": int(CALC_FNS["mobile_users"](dom)),
        "cp_n_cc_users": int(all_stats["commcare_users"].get(dom, 0)),
        "cp_n_active_cases": int(CALC_FNS["cases_in_last"](dom, 120)),
        "cp_n_users_submitted_form": total_distinct_users(dom),
        "cp_n_inactive_cases": int(CALC_FNS["inactive_cases_in_last"](dom,
                                                                      120)),
        "cp_n_30_day_cases": int(CALC_FNS["cases_in_last"](dom, 30)),
        "cp_n_60_day_cases": int(CALC_FNS["cases_in_last"](dom, 60)),
        "cp_n_90_day_cases": int(CALC_FNS["cases_in_last"](dom, 90)),
        "cp_n_cases": int(CALC_FNS["cases"](dom)),
        "cp_n_forms": int(CALC_FNS["forms"](dom)),
        "cp_n_forms_30_d": int(CALC_FNS["forms_in_last"](dom, 30)),
        "cp_n_forms_60_d": int(CALC_FNS["forms_in_last"](dom, 60)),
        "cp_n_forms_90_d": int(CALC_FNS["forms_in_last"](dom, 90)),
        "cp_first_domain_for_user": CALC_FNS["first_domain_for_user"](dom),
        "cp_first_form": CALC_FNS["first_form_submission"](dom, False),
        "cp_last_form": CALC_FNS["last_form_submission"](dom, False),
        "cp_is_active": CALC_FNS["active"](dom),
        "cp_has_app": CALC_FNS["has_app"](dom),
        "cp_last_updated": json_format_datetime(datetime.utcnow()),
        "cp_n_in_sms": int(CALC_FNS["sms"](dom, "I")),
        "cp_n_out_sms": int(CALC_FNS["sms"](dom, "O")),
        "cp_n_sms_ever": int(CALC_FNS["sms_in_last"](dom)),
        "cp_n_sms_30_d": int(CALC_FNS["sms_in_last"](dom, 30)),
        "cp_n_sms_60_d": int(CALC_FNS["sms_in_last"](dom, 60)),
        "cp_n_sms_90_d": int(CALC_FNS["sms_in_last"](dom, 90)),
        "cp_sms_ever": int(CALC_FNS["sms_in_last_bool"](dom)),
        "cp_sms_30_d": int(CALC_FNS["sms_in_last_bool"](dom, 30)),
        "cp_n_sms_in_30_d": int(CALC_FNS["sms_in_in_last"](dom, 30)),
        "cp_n_sms_in_60_d": int(CALC_FNS["sms_in_in_last"](dom, 60)),
        "cp_n_sms_in_90_d": int(CALC_FNS["sms_in_in_last"](dom, 90)),
        "cp_n_sms_out_30_d": int(CALC_FNS["sms_out_in_last"](dom, 30)),
        "cp_n_sms_out_60_d": int(CALC_FNS["sms_out_in_last"](dom, 60)),
        "cp_n_sms_out_90_d": int(CALC_FNS["sms_out_in_last"](dom, 90)),
        "cp_n_j2me_30_d": int(CALC_FNS["j2me_forms_in_last"](dom, 30)),
        "cp_n_j2me_60_d": int(CALC_FNS["j2me_forms_in_last"](dom, 60)),
        "cp_n_j2me_90_d": int(CALC_FNS["j2me_forms_in_last"](dom, 90)),
        "cp_j2me_90_d_bool": int(CALC_FNS["j2me_forms_in_last_bool"](dom, 90)),
        "cp_300th_form": CALC_FNS["300th_form_submission"](dom),
        "cp_n_30_day_user_cases": cases_in_last(dom,
                                                30,
                                                case_type="commcare-user"),
        "cp_n_trivet_backends": num_telerivet_backends(dom),
        "cp_use_domain_security": use_domain_security_settings(dom),
        "cp_n_custom_roles": num_custom_roles(dom),
        "cp_using_locations": users_have_locations(dom),
        "cp_n_loc_restricted_roles": num_location_restricted_roles(dom),
        "cp_n_case_sharing_olevels": num_case_sharing_loc_types(dom),
        "cp_n_case_sharing_groups": num_case_sharing_groups(dom),
        "cp_n_repeaters": num_repeaters(dom),
        "cp_n_case_exports": num_exports(dom),
        "cp_n_deid_exports": num_deid_exports(dom),
        "cp_n_saved_exports": num_saved_exports(dom),
        "cp_n_rb_reports": number_of_report_builder_reports(dom),
        "cp_n_ucr_reports": number_of_ucr_reports(dom),
        "cp_n_lookup_tables": num_lookup_tables(dom),
        "cp_has_project_icon": has_domain_icon(dom),
        "cp_n_apps_with_icon": num_apps_with_icon(dom),
        "cp_n_apps": len(_get_domain_apps(dom)),
        "cp_n_apps_with_multi_lang": num_apps_with_multi_languages(dom),
    }
Esempio n. 9
0
def calced_props(dom, id, all_stats):
    return {
        "_id": id,
        "cp_n_web_users": int(all_stats["web_users"].get(dom, 0)),
        "cp_n_active_cc_users": int(CALC_FNS["mobile_users"](dom)),
        "cp_n_cc_users": int(all_stats["commcare_users"].get(dom, 0)),
        "cp_n_active_cases": int(CALC_FNS["cases_in_last"](dom, 120)),
        "cp_n_users_submitted_form": total_distinct_users(dom),
        "cp_n_inactive_cases": int(CALC_FNS["inactive_cases_in_last"](dom, 120)),
        "cp_n_30_day_cases": int(CALC_FNS["cases_in_last"](dom, 30)),
        "cp_n_60_day_cases": int(CALC_FNS["cases_in_last"](dom, 60)),
        "cp_n_90_day_cases": int(CALC_FNS["cases_in_last"](dom, 90)),
        "cp_n_cases": int(CALC_FNS["cases"](dom)),
        "cp_n_forms": int(CALC_FNS["forms"](dom)),
        "cp_n_forms_30_d": int(CALC_FNS["forms_in_last"](dom, 30)),
        "cp_n_forms_60_d": int(CALC_FNS["forms_in_last"](dom, 60)),
        "cp_n_forms_90_d": int(CALC_FNS["forms_in_last"](dom, 90)),
        "cp_first_domain_for_user": CALC_FNS["first_domain_for_user"](dom),
        "cp_first_form": CALC_FNS["first_form_submission"](dom, False),
        "cp_last_form": CALC_FNS["last_form_submission"](dom, False),
        "cp_is_active": CALC_FNS["active"](dom),
        "cp_has_app": CALC_FNS["has_app"](dom),
        "cp_last_updated": json_format_datetime(datetime.utcnow()),
        "cp_n_in_sms": int(CALC_FNS["sms"](dom, "I")),
        "cp_n_out_sms": int(CALC_FNS["sms"](dom, "O")),
        "cp_n_sms_ever": int(CALC_FNS["sms_in_last"](dom)),
        "cp_n_sms_30_d": int(CALC_FNS["sms_in_last"](dom, 30)),
        "cp_n_sms_60_d": int(CALC_FNS["sms_in_last"](dom, 60)),
        "cp_n_sms_90_d": int(CALC_FNS["sms_in_last"](dom, 90)),
        "cp_sms_ever": int(CALC_FNS["sms_in_last_bool"](dom)),
        "cp_sms_30_d": int(CALC_FNS["sms_in_last_bool"](dom, 30)),
        "cp_n_sms_in_30_d": int(CALC_FNS["sms_in_in_last"](dom, 30)),
        "cp_n_sms_in_60_d": int(CALC_FNS["sms_in_in_last"](dom, 60)),
        "cp_n_sms_in_90_d": int(CALC_FNS["sms_in_in_last"](dom, 90)),
        "cp_n_sms_out_30_d": int(CALC_FNS["sms_out_in_last"](dom, 30)),
        "cp_n_sms_out_60_d": int(CALC_FNS["sms_out_in_last"](dom, 60)),
        "cp_n_sms_out_90_d": int(CALC_FNS["sms_out_in_last"](dom, 90)),
        "cp_n_j2me_30_d": int(CALC_FNS["j2me_forms_in_last"](dom, 30)),
        "cp_n_j2me_60_d": int(CALC_FNS["j2me_forms_in_last"](dom, 60)),
        "cp_n_j2me_90_d": int(CALC_FNS["j2me_forms_in_last"](dom, 90)),
        "cp_j2me_90_d_bool": int(CALC_FNS["j2me_forms_in_last_bool"](dom, 90)),
        "cp_300th_form": CALC_FNS["300th_form_submission"](dom),
        "cp_n_30_day_user_cases": cases_in_last(dom, 30, case_type="commcare-user"),
        "cp_n_trivet_backends": num_telerivet_backends(dom),
        "cp_use_domain_security": use_domain_security_settings(dom),
        "cp_n_custom_roles": num_custom_roles(dom),
        "cp_using_locations": users_have_locations(dom),
        "cp_n_loc_restricted_roles": num_location_restricted_roles(dom),
        "cp_n_case_sharing_olevels": num_case_sharing_loc_types(dom),
        "cp_n_case_sharing_groups": num_case_sharing_groups(dom),
        "cp_n_repeaters": num_repeaters(dom),
        "cp_n_case_exports": num_exports(dom),
        "cp_n_deid_exports": num_deid_exports(dom),
        "cp_n_saved_exports": num_saved_exports(dom),
        "cp_n_rb_reports": number_of_report_builder_reports(dom),
        "cp_n_ucr_reports": number_of_ucr_reports(dom),
        "cp_n_lookup_tables": num_lookup_tables(dom),
        "cp_has_project_icon": has_domain_icon(dom),
        "cp_n_apps_with_icon": num_apps_with_icon(dom),
        "cp_n_apps": len(_get_domain_apps(dom)),
        "cp_n_apps_with_multi_lang": num_apps_with_multi_languages(dom),
        "cp_n_saved_custom_exports": get_export_count_by_domain(dom),
    }