def test_rule(offline_event, user):
    project = offline_event.project
    anonymous, moderator, initiator = setup_users(project)

    assert rules.has_perm(perm_name, anonymous, offline_event)
    assert rules.has_perm(perm_name, user, offline_event)
    assert rules.has_perm(perm_name, moderator, offline_event)
    assert rules.has_perm(perm_name, initiator, offline_event)
def test_rule(plan, project, user):
    plan.projects.add(project)
    anonymous, moderator, initiator = setup_users(project)

    assert not rules.has_perm(perm_name, anonymous, plan.organisation)
    assert not rules.has_perm(perm_name, user, plan.organisation)
    assert not rules.has_perm(perm_name, moderator, plan.organisation)
    assert rules.has_perm(perm_name, initiator, plan.organisation)
Beispiel #3
0
def test_rule(plan, user, project):
    plan.projects.add(project)
    anonymous, moderator, initiator = setup_users(project)

    assert rules.has_perm(perm_name, anonymous, None)
    assert rules.has_perm(perm_name, user, None)
    assert rules.has_perm(perm_name, moderator, None)
    assert rules.has_perm(perm_name, initiator, None)
def test_rule_project_archived(offline_event_factory, user):
    offline_event = offline_event_factory(project__is_archived=True)
    project = offline_event.project
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_archived
    assert rules.has_perm(perm_name, anonymous, offline_event)
    assert rules.has_perm(perm_name, user, offline_event)
    assert rules.has_perm(perm_name, moderator, offline_event)
    assert rules.has_perm(perm_name, initiator, offline_event)
def test_pre_phase(phase_factory, poll_factory, question, choice, vote, user):
    phase, module, project, _ = setup_phase(phase_factory, poll_factory,
                                            phases.VotingPhase)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_public
    with freeze_pre_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, module)
        assert not rules.has_perm(perm_name, user, module)
        assert rules.has_perm(perm_name, moderator, module)
        assert rules.has_perm(perm_name, initiator, module)
Beispiel #6
0
def test_phase_active(phase_factory, map_idea_factory, user):
    phase, _, project, item = setup_phase(phase_factory, map_idea_factory,
                                          phases.CollectPhase)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_public
    with freeze_phase(phase):
        assert rules.has_perm(perm_name, anonymous, item)
        assert rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
Beispiel #7
0
def test_pre_phase(phase_factory, maptopic_factory, user):
    phase, _, project, item = setup_phase(phase_factory, maptopic_factory,
                                          phases.PrioritizePhase)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_public
    with freeze_pre_phase(phase):
        assert rules.has_perm(perm_name, anonymous, item)
        assert rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
def test_pre_phase(phase_factory, proposal_factory, user):
    phase, _, project, item = setup_phase(phase_factory, proposal_factory,
                                          phases.RequestPhase)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_public
    with freeze_pre_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert not rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
def test_phase_active(phase_factory, user):
    phase, module, project, _ = setup_phase(phase_factory, None,
                                            phases.RequestPhase)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_public
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, module)
        assert rules.has_perm(perm_name, user, module)
        assert rules.has_perm(perm_name, moderator, module)
        assert rules.has_perm(perm_name, initiator, module)
Beispiel #10
0
def setup_mapidea_moderation():
    phase, module, project, item = setup_phase(PhaseFactory, MapIdeaFactory,
                                               phases.FeedbackPhase)
    anonymous, moderator, initiator = setup_users(project)
    with freeze_phase(phase):
        url = reverse('meinberlin_mapideas:mapidea-moderate',
                      kwargs={
                          'pk': item.pk,
                          'year': item.created.year
                      })
        return anonymous, moderator, initiator, url
Beispiel #11
0
def test_phase_active_project_draft(phase_factory, maptopic_factory, user):
    phase, _, project, item = setup_phase(phase_factory, maptopic_factory,
                                          phases.PrioritizePhase,
                                          module__project__is_draft=True)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_draft
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert not rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
def test_post_phase_project_archived(phase_factory, user):
    phase, module, project, _ = setup_phase(phase_factory, None,
                                            phases.CollectPhase,
                                            module__project__is_archived=True)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_archived
    with freeze_post_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, module)
        assert not rules.has_perm(perm_name, user, module)
        assert rules.has_perm(perm_name, moderator, module)
        assert rules.has_perm(perm_name, initiator, module)
def test_post_phase_project_archived(phase_factory, idea_factory, user):
    phase, _, project, item = setup_phase(phase_factory, idea_factory,
                                          phases.RatingPhase,
                                          module__project__is_archived=True)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_archived
    with freeze_post_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert not rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
Beispiel #14
0
def test_phase_active(phase_factory, chapter_factory, paragraph_factory, user):
    phase, _, project, item = setup_phase(phase_factory, chapter_factory,
                                          phases.CommentPhase)
    anonymous, moderator, initiator = setup_users(project)
    paragraph = paragraph_factory(chapter=item)

    assert project.is_public
    with freeze_phase(phase):
        assert rules.has_perm(perm_name, anonymous, paragraph)
        assert rules.has_perm(perm_name, user, paragraph)
        assert rules.has_perm(perm_name, moderator, paragraph)
        assert rules.has_perm(perm_name, initiator, paragraph)
def test_phase_active_project_draft(phase_factory, user):
    phase, module, project, _ = setup_phase(phase_factory,
                                            None,
                                            phases.CommentPhase,
                                            module__project__is_draft=True)
    anonymous, moderator, initiator = setup_users(project)

    assert project.is_draft
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, module)
        assert not rules.has_perm(perm_name, user, module)
        assert rules.has_perm(perm_name, moderator, module)
        assert rules.has_perm(perm_name, initiator, module)
Beispiel #16
0
def test_phase_active(phase_factory, poll_factory, user):
    phase, _, project, item = setup_phase(phase_factory, poll_factory,
                                          phases.VotingPhase)
    anonymous, moderator, initiator = setup_users(project)
    creator = item.creator

    assert project.is_public
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, creator, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
def test_phase_active_project_draft(phase_factory, idea_factory, user):
    phase, _, project, item = setup_phase(phase_factory, idea_factory,
                                          phases.CollectPhase,
                                          module__project__is_draft=True)
    anonymous, moderator, initiator = setup_users(project)
    creator = item.creator

    assert project.is_draft
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert not rules.has_perm(perm_name, user, item)
        assert not rules.has_perm(perm_name, creator, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
Beispiel #18
0
def test_rule(project, user_factory, group_factory):
    organisation = project.organisation
    anonymous, moderator, initiator = setup_users(project)

    group = group_factory()
    user = user_factory()
    group_user = user_factory(groups=(group,))
    organisation.groups.add(group)

    assert not rules.has_perm(perm_name, anonymous, organisation)
    assert not rules.has_perm(perm_name, user, organisation)
    assert not rules.has_perm(perm_name, moderator, organisation)
    assert not rules.has_perm(perm_name, group_user, organisation)
    assert rules.has_perm(perm_name, initiator, organisation)
def test_facetoface_in_blueprints(client, project):
    anonymous, moderator, initiator = setup_users(project)
    client.login(username=initiator.email, password='******')
    blueprints_url = reverse(
        'a4dashboard:blueprint-list',
        kwargs={'organisation_slug': project.organisation.slug})
    # facetoface_blueprint_url = reverse(
    #     'a4dashboard:project-create',
    #     kwargs={
    #         'blueprint_slug': 'facetoface',
    #         'organisation_slug': project.organisation.slug
    #     })
    resp = client.get(blueprints_url, follow=True)
    assert resp.status_code == 200
Beispiel #20
0
def test_post_phase_project_archived(phase_factory, topic_factory, user):
    phase, _, project, item = setup_phase(phase_factory, topic_factory,
                                          phases.PrioritizePhase,
                                          module__project__is_archived=True)
    anonymous, moderator, initiator = setup_users(project)
    creator = item.creator

    assert project.is_archived
    with freeze_post_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert not rules.has_perm(perm_name, user, item)
        assert not rules.has_perm(perm_name, creator, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
Beispiel #21
0
def test_phase_active_project_private(phase_factory, maptopic_factory,
                                      user, user2):
    phase, _, project, item = setup_phase(phase_factory, maptopic_factory,
                                          phases.PrioritizePhase,
                                          module__project__is_public=False)
    anonymous, moderator, initiator = setup_users(project)
    participant = user2
    project.participants.add(participant)

    assert not project.is_public
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, item)
        assert not rules.has_perm(perm_name, user, item)
        assert rules.has_perm(perm_name, participant, item)
        assert rules.has_perm(perm_name, moderator, item)
        assert rules.has_perm(perm_name, initiator, item)
def test_phase_active_project_private(phase_factory, user, user2):
    phase, module, project, _ = setup_phase(phase_factory, None,
                                            phases.CollectPhase,
                                            module__project__is_public=False)
    anonymous, moderator, initiator = setup_users(project)

    participant = user2
    project.participants.add(participant)

    assert not project.is_public
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, module)
        assert not rules.has_perm(perm_name, user, module)
        assert rules.has_perm(perm_name, participant, module)
        assert rules.has_perm(perm_name, moderator, module)
        assert rules.has_perm(perm_name, initiator, module)
Beispiel #23
0
def test_phase_active_project_private(phase_factory, chapter_factory,
                                      paragraph_factory, user, user2):
    phase, _, project, item = setup_phase(phase_factory, chapter_factory,
                                          phases.CommentPhase,
                                          module__project__is_public=False)
    anonymous, moderator, initiator = setup_users(project)
    participant = user2
    project.participants.add(participant)
    paragraph = paragraph_factory(chapter=item)

    assert not project.is_public
    with freeze_phase(phase):
        assert not rules.has_perm(perm_name, anonymous, paragraph)
        assert not rules.has_perm(perm_name, user, paragraph)
        assert rules.has_perm(perm_name, participant, paragraph)
        assert rules.has_perm(perm_name, moderator, paragraph)
        assert rules.has_perm(perm_name, initiator, paragraph)
def test_create_activity_in_dashboard(user, client, activity_factory,
                                      phase_factory):
    activity = activity_factory()
    phase_factory(module=activity.module)
    anonymous, moderator, initiator = setup_users(activity.project)
    client.login(username=initiator.email, password='******')
    url = reverse('a4dashboard:activities-dashboard',
                  kwargs={'module_slug': activity.module.slug})
    # get the page
    resp = client.get(url)
    assert resp.status_code == 200

    # post invalid data
    resp = client.post(url)
    assert not resp.context['form'].is_valid()

    # post valid data
    resp = client.post(url, {
        'name': 'myname',
        'highlight': 'myhilight',
        'description': 'mydescription'
    })
    assert resp.status_code == 302  # use this an an indicator for success
Beispiel #25
0
def test_user_is_project_admin(project, user):
    anonymous, moderator, initiator = setup_users(project)
    assert not _user_is_project_admin(anonymous)
    assert not _user_is_project_admin(user)
    assert _user_is_project_admin(moderator)
    assert _user_is_project_admin(initiator)