Projects under organizations with fixed URL name and feature ID prefix, three visibility levels, open contribution, per-project roles, settings and typed-confirmation delete. Hidden projects 404. Leaving an org drops its project roles. Project access rules live in intent/access.py alongside org access. Features numbered per project (INT-12) in a tree. Every change is a revision with a required note; history, old revisions, and side-by-side field and line diffs between any two. Cycles and superseded-without-replacement are rejected. Markdown renders safely with source-line attributes for Phase 3 line comments and headings shifted below the page h1. Server-side preview works without JS. Structural accessibility check runs on every page in tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
import itertools
|
|
|
|
import pytest
|
|
from allauth.account.models import EmailAddress
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from intent.orgs.models import OrgMembership, Role
|
|
from intent.orgs.services import create_org
|
|
from intent.projects.models import ProjectMembership, Visibility
|
|
from intent.projects.services import create_project
|
|
|
|
_counter = itertools.count()
|
|
|
|
|
|
@pytest.fixture
|
|
def make_user(db):
|
|
def make(username=None, *, email=None, is_staff=False):
|
|
username = username or f"user{next(_counter)}"
|
|
email = email or f"{username}@example.com"
|
|
user = get_user_model().objects.create_user(
|
|
username=username, email=email, is_staff=is_staff
|
|
)
|
|
EmailAddress.objects.create(user=user, email=email, verified=True, primary=True)
|
|
return user
|
|
|
|
return make
|
|
|
|
|
|
@pytest.fixture
|
|
def owner(make_user):
|
|
return make_user("olive")
|
|
|
|
|
|
@pytest.fixture
|
|
def org(owner):
|
|
return create_org(slug="catbriar", name="Catbriar", owner=owner)
|
|
|
|
|
|
@pytest.fixture
|
|
def collaborator(make_user, org):
|
|
user = make_user("cole")
|
|
OrgMembership.objects.create(org=org, user=user, role=Role.COLLABORATOR)
|
|
return user
|
|
|
|
|
|
@pytest.fixture
|
|
def project(org, owner):
|
|
"""A private project created by the org owner, who is therefore its project owner too."""
|
|
return create_project(
|
|
org,
|
|
owner,
|
|
slug="intent",
|
|
name="Intent",
|
|
feature_prefix="INT",
|
|
visibility=Visibility.PRIVATE,
|
|
open_contribution=False,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def editor(make_user, org, project):
|
|
"""An org collaborator who is a collaborator on the project."""
|
|
user = make_user("eddie")
|
|
OrgMembership.objects.create(org=org, user=user)
|
|
ProjectMembership.objects.create(project=project, user=user)
|
|
return user
|