To reduce the repetition, why not structure this with an if for the read only then in that block an if for the other conditions, e.g.

```python
if readonly:
    owner = ...
    formid = ...
    if 'public' in [owner, formid] or request.user.is_anonymous():
        return True
...
```