def get_user_MS(self, subject, region, period): member_states = [] if admin_perm.can() or sta_perm.can(): member_states = self.get_MS(subject, region, period) elif nat_perm.can() and current_user.MS: member_states = [(current_user.MS, current_user.MS)] return member_states + [(DEFAULT_MS, DEFAULT_MS)]
def get_user_MS(self, subject, region, period): member_states = [] if admin_perm.can() or sta_perm.can(): member_states = self.get_MS(subject, region, period) elif nat_perm.can() and current_user.MS: member_states = [(current_user.MS, current_user.MS)] return member_states + [(DEFAULT_MS, DEFAULT_MS)]
def can_touch(assessment): if current_user.is_anonymous() and not EU_ASSESSMENT_MODE: return False if not assessment: return EU_ASSESSMENT_MODE or admin_perm.can() or nat_perm.can() or etc_perm.can() or ( sta_perm.can() and not consultation_ended()) return EU_ASSESSMENT_MODE or admin_perm.can() or etc_perm.can() or ( assessment.user == current_user and not sta_cannot_change())
def can_touch(assessment): if current_user.is_anonymous() and not EU_ASSESSMENT_MODE: return False if not assessment: return EU_ASSESSMENT_MODE or admin_perm.can() or nat_perm.can( ) or etc_perm.can() or (sta_perm.can() and not consultation_ended()) return EU_ASSESSMENT_MODE or admin_perm.can() or etc_perm.can() or ( assessment.user == current_user and not sta_cannot_change())
def can_add_conclusion(dataset, zone, subject, region=None): """ Zone: one of 'species', 'habitat' """ from art17.summary.views import SpeciesSummary, HabitatSummary zone_cls_mapping = {'species': SpeciesSummary, 'habitat': HabitatSummary} can_add = False warning_message = '' if not dataset: warning_message = 'Please select a valid dataset in order to add ' + \ 'a conclusion.' elif dataset.is_readonly: warning_message = 'The current dataset is readonly, so you cannot ' + \ 'add a conclusion.' elif not region: warning_message = 'Please select a Bioregion in order to add a ' + \ 'conclusion.' elif not (admin_perm.can() or sta_perm.can() or nat_perm.can() or etc_perm.can() or EU_ASSESSMENT_MODE): warning_message = 'You do not have permission to add conclusions.' elif sta_cannot_change(): warning_message = 'The consultation period has ended; you cannont ' + \ 'add conclusions anymore.' else: if not EU_ASSESSMENT_MODE: record_exists = zone_cls_mapping[zone].get_manual_record( dataset.id, subject, region, current_user.id) if record_exists: warning_message = 'You have already added a conclusion for ' + \ 'the selected subject and region.' else: can_add = True else: can_add = True return can_add, warning_message
def can_add_conclusion(dataset, zone, subject, region=None): """ Zone: one of 'species', 'habitat' """ from art17.summary.views import SpeciesSummary, HabitatSummary zone_cls_mapping = {'species': SpeciesSummary, 'habitat': HabitatSummary} can_add = False warning_message = '' if not dataset: warning_message = 'Please select a valid dataset in order to add ' + \ 'a conclusion.' elif dataset.is_readonly: warning_message = 'The current dataset is readonly, so you cannot ' + \ 'add a conclusion.' elif not region: warning_message = 'Please select a Bioregion in order to add a ' + \ 'conclusion.' elif not (admin_perm.can() or sta_perm.can() or nat_perm.can() or etc_perm.can() or EU_ASSESSMENT_MODE): warning_message = 'You do not have permission to add conclusions.' elif sta_cannot_change(): warning_message = 'The consultation period has ended; you cannont ' + \ 'add conclusions anymore.' else: if not EU_ASSESSMENT_MODE: record_exists = zone_cls_mapping[zone].get_manual_record( dataset.id, subject, region, current_user.id) if record_exists: warning_message = 'You have already added a conclusion for ' + \ 'the selected subject and region.' else: can_add = True else: can_add = True return can_add, warning_message
def can_post_comment(record): if EU_ASSESSMENT_MODE: return True if not current_user.is_authenticated: return False if record.dataset and record.dataset.is_readonly: return False can_add = False if sta_cannot_change(): can_add = False elif sta_perm.can() or nat_perm.can(): if (record.user.has_role('nat') and record.user_id == current_user.id) \ or not record.user or record.user.has_role('stakeholder'): can_add = True else: can_add = True if can_add: authors = [c.author_id for c in record.comments] if current_user.id in authors: return False return not record.deleted and can_add
def can_post_comment(record): if EU_ASSESSMENT_MODE: return True if not current_user.is_authenticated(): return False if record.dataset and record.dataset.is_readonly: return False can_add = False if sta_cannot_change(): can_add = False elif sta_perm.can() or nat_perm.can(): if (record.user.has_role('nat') and record.user_id == current_user.id) \ or not record.user or record.user.has_role('stakeholder'): can_add = True else: can_add = True if can_add: authors = [c.author_id for c in record.comments] if current_user.id in authors: return False return not record.deleted and can_add
def can_select_MS(): return admin_perm.can() or sta_perm.can() or nat_perm.can()
def can_select_MS(): return admin_perm.can() or sta_perm.can() or nat_perm.can()