Beispiel #1
0
 def get_context_data(self, **kwargs):
     context = super(CommCareUserSelfRegistrationView, self).get_context_data(**kwargs)
     context.update({
         'form': self.form,
         'invitation': self.invitation,
         'can_add_extra_mobile_workers': can_add_extra_mobile_workers(self.request),
         'google_play_store_url': 'https://play.google.com/store/apps/details?id=org.commcare.dalvik&hl=en',
     })
     return context
Beispiel #2
0
 def get_context_data(self, **kwargs):
     context = super(CommCareUserSelfRegistrationView, self).get_context_data(**kwargs)
     context.update({
         'hr_name': self.domain_object.display_name(),
         'form': self.form,
         'invitation': self.invitation,
         'can_add_extra_mobile_workers': can_add_extra_mobile_workers(self.request),
         'google_play_store_url': GOOGLE_PLAY_STORE_COMMCARE_URL,
     })
     return context
Beispiel #3
0
 def get_context_data(self, **kwargs):
     context = super(CommCareUserSelfRegistrationView, self).get_context_data(**kwargs)
     context.update({
         'hr_name': self.domain_object.display_name(),
         'form': self.form,
         'invitation': self.invitation,
         'can_add_extra_mobile_workers': can_add_extra_mobile_workers(self.request),
         'google_play_store_url': GOOGLE_PLAY_STORE_COMMCARE_URL,
     })
     return context
Beispiel #4
0
 def get_context_data(self, **kwargs):
     context = super(CommCareUserSelfRegistrationView,
                     self).get_context_data(**kwargs)
     context.update({
         'form':
         self.form,
         'invitation':
         self.invitation,
         'can_add_extra_mobile_workers':
         can_add_extra_mobile_workers(self.request),
         'google_play_store_url':
         'https://play.google.com/store/apps/details?id=org.commcare.dalvik&hl=en',
     })
     return context
Beispiel #5
0
def archive_commcare_user(request, domain, user_id, is_active=False):
    can_add_extra_users = can_add_extra_mobile_workers(request)
    if not can_add_extra_users and is_active:
        return HttpResponse(json.dumps({
            'success': False,
            'message': _("You are not allowed to add additional mobile workers"),
        }))
    user = CommCareUser.get_by_user_id(user_id, domain)
    user.is_active = is_active
    user.save()
    return HttpResponse(json.dumps(dict(
        success=True,
        message=_("User '{user}' has successfully been {action}.").format(
            user=user.raw_username,
            action=_("Reactivated") if user.is_active else _("Deactivated"),
        )
    )))
Beispiel #6
0
def archive_commcare_user(request, domain, user_id, is_active=False):
    can_add_extra_users = can_add_extra_mobile_workers(request)
    if not can_add_extra_users and is_active:
        return HttpResponse(json.dumps({
            'success': False,
            'message': _("You are not allowed to add additional mobile workers"),
        }))
    user = CommCareUser.get_by_user_id(user_id, domain)
    user.is_active = is_active
    user.save()
    return HttpResponse(json.dumps(dict(
        success=True,
        message=_("User '{user}' has successfully been {action}.").format(
            user=user.raw_username,
            action=_("Reactivated") if user.is_active else _("Deactivated"),
        )
    )))
Beispiel #7
0
def _modify_user_status(request, domain, user_id, is_active):
    user = CommCareUser.get_by_user_id(user_id, domain)
    if (not _can_edit_workers_location(request.couch_user, user)
            or (is_active and not can_add_extra_mobile_workers(request))):
        return json_response({
            'error': _("No Permission."),
        })
    if not is_active and user.user_location_id:
        return json_response({
            'error': _("This is a location user, archive or delete the "
                       "corresponding location to deactivate it."),
        })
    user.is_active = is_active
    user.save(spawn_task=True)
    return json_response({
        'success': True,
    })
Beispiel #8
0
def _modify_user_status(request, domain, user_id, is_active):
    user = CommCareUser.get_by_user_id(user_id, domain)
    if (not _can_edit_workers_location(request.couch_user, user)
            or (is_active and not can_add_extra_mobile_workers(request))):
        return json_response({
            'error': _("No Permission."),
        })
    if not is_active and user.user_location_id:
        return json_response({
            'error': _("This is a location user, archive or delete the "
                       "corresponding location to deactivate it."),
        })
    user.is_active = is_active
    user.save(spawn_task=True)
    return json_response({
        'success': True,
    })
Beispiel #9
0
 def dispatch(self, request, *args, **kwargs):
     if not can_add_extra_mobile_workers(request):
         raise PermissionDenied()
     return super(CreateCommCareUserModal,
                  self).dispatch(request, *args, **kwargs)
Beispiel #10
0
 def can_add_extra_users(self):
     return can_add_extra_mobile_workers(self.request)
Beispiel #11
0
 def dispatch(self, request, *args, **kwargs):
     if not can_add_extra_mobile_workers(request):
         return HttpResponseRedirect(reverse(ListCommCareUsersView.urlname, args=[self.domain]))
     return super(CreateCommCareUserView, self).dispatch(request, *args, **kwargs)
Beispiel #12
0
 def can_add_extra_users(self):
     return can_add_extra_mobile_workers(self.request)
Beispiel #13
0
 def dispatch(self, request, *args, **kwargs):
     if not can_add_extra_mobile_workers(request):
         raise PermissionDenied()
     return super(CreateCommCareUserModal, self).dispatch(request, *args, **kwargs)
Beispiel #14
0
 def dispatch(self, request, *args, **kwargs):
     if not can_add_extra_mobile_workers(request):
         return HttpResponseRedirect(reverse(ListCommCareUsersView.urlname, args=[self.domain]))
     return super(CreateCommCareUserView, self).dispatch(request, *args, **kwargs)