def test_should_return_DataSubmission_for_reporter(self): user = self._get_reporter_user() request = MagicMock() organization = MagicMock(spec=Organization) with patch('datawinners.alldata.helper.get_organization') as mock_get_organization: mock_get_organization.return_value = organization request.user = user assert helper.get_page_heading(request) == 'Data Submission'
def test_should_return_AllData_for_pro_sms_account(self): user = self._get_normal_user() request = MagicMock() organization = MagicMock(spec=Organization) organization.is_pro_sms = True with patch('datawinners.alldata.helper.get_organization') as mock_get_organization: mock_get_organization.return_value = organization request.user = user assert helper.get_page_heading(request) == 'Questionnaires & Polls'
def test_should_return_AllData_for_trial_and_pro_account(self): user = get_project_manager() request = MagicMock() organization = MagicMock(spec=Organization) organization.is_pro_sms = False with patch('datawinners.alldata.helper.get_organization' ) as mock_get_organization: mock_get_organization.return_value = organization request.user = user assert helper.get_page_heading(request) == 'Questionnaires'
def index(request): organization = get_organization(request) page_heading = get_page_heading(request) hide_for_data_sender = 'none' if request.user.get_profile( ).reporter else '' rows = get_project_list(request) project_list = [] smart_phone_instruction_link = reverse("smart_phone_instruction") local_time_delta = get_country_time_delta(organization.country) for project in rows: project_list.append( _construct_project_dict(request.user, local_time_delta, project)) project_list.sort(key=itemgetter('name')) activation_success = request.GET.get('activation', False) error_messages = [] if "associate" in request.GET.keys(): error_messages = [ _('You may have been dissociated from the project. Please contact your administrator for more details.' ) ] if is_crs_admin(request): return render_to_response('alldata/index.html', { 'projects': project_list, 'page_heading': page_heading, 'is_crs_admin': True, 'project_links': get_alldata_project_links(), 'is_quota_reached': is_quota_reached(request), 'error_messages': error_messages, 'is_pro_sms': organization.is_pro_sms, 'activation_success': activation_success, 'hide_for_data_sender': hide_for_data_sender, 'current_lang': get_language() }, context_instance=RequestContext(request)) else: return render_to_response('alldata/index.html', { 'projects': project_list, 'page_heading': page_heading, 'is_crs_admin': False, "smart_phone_instruction_link": smart_phone_instruction_link, 'project_links': get_alldata_project_links(), 'is_quota_reached': is_quota_reached(request), 'error_messages': error_messages, 'is_pro_sms': organization.is_pro_sms, 'activation_success': activation_success, 'hide_for_data_sender': hide_for_data_sender, 'current_lang': get_language() }, context_instance=RequestContext(request))
def index(request): organization = get_organization(request) page_heading = get_page_heading(request) hide_for_data_sender = 'none' if request.user.get_profile( ).reporter else '' project_list = [] smart_phone_instruction_link = reverse("smart_phone_instruction") activation_success = request.GET.get('activation', False) error_messages = [] if "associate" in request.GET.keys(): error_messages = [ _('You may have been dissociated from the project. Please contact your administrator for more details.' ) ] if is_crs_admin(request): return render_to_response('alldata/index.html', { 'projects': project_list, 'page_heading': page_heading, 'is_crs_admin': True, 'project_links': get_alldata_project_links(), 'is_quota_reached': is_quota_reached(request), 'error_messages': error_messages, 'is_pro_sms': organization.is_pro_sms, 'activation_success': activation_success, 'hide_for_data_sender': hide_for_data_sender, 'hide_link_class': hide_for_data_sender, 'current_lang': get_language() }, context_instance=RequestContext(request)) else: return render_to_response('alldata/index.html', { 'projects': project_list, 'page_heading': page_heading, 'is_crs_admin': False, "smart_phone_instruction_link": smart_phone_instruction_link, 'project_links': get_alldata_project_links(), 'is_quota_reached': is_quota_reached(request), 'error_messages': error_messages, 'is_pro_sms': organization.is_pro_sms, 'activation_success': activation_success, 'hide_for_data_sender': hide_for_data_sender, 'hide_link_class': hide_for_data_sender, 'user_group': request.user.groups.all()[0].name, 'current_lang': get_language() }, context_instance=RequestContext(request))
def test_should_return_AllData_for_other(self): user = self._get_normal_user() assert helper.get_page_heading(user) == 'All Data'
def test_should_return_DataSubmission_for_reporter(self): user = self._get_reporter_user() assert helper.get_page_heading(user) == 'Data Submission'
def projects_index(request): disable_link_class, hide_link_class = get_visibility_settings_for(request.user) page_heading = get_page_heading(request.user) return disable_link_class, hide_link_class, page_heading