etianen/django-reversion — Issue #120: Display reversion as readonly
Author: ahernp
Created: 2012-01-18 20:37:24+00:00
State: open

Thank you very much for `django-reversion`, it has frequently been a lifesaver for me.

May I suggest displaying the reversions as readonly? It seems strange to me that a user can edit the reversion just before reverting to it.

A change to `render_revision_form` in `reversion.admin` has this effect. Replace the calls to the `get_readonly_fields` function with calls to this function which returns a list of all the fields in the model (or inline):

```python
def list_all_fields(obj):
"""
Return list of the names of all fields in model.
Used instead of get_readonly_fields to make everything readonly.
"""
from django.db.models import Model
fields = []
field_names = []
if issubclass(obj.__class__, Model): # Model
fields = obj._meta.fields
elif hasattr(obj, 'model'): # Inline object
fields = obj.model._meta.fields
for field in fields:
field_names.append(field.name)
return field_names
```

```
- self.prepopulated_fields, self.get_readonly_fields(request, obj),
- model_admin=self)
+ self.prepopulated_fields, list_all_fields(obj),
+ model_admin = self)
. . .
- readonly = list(inline.get_readonly_fields(request, obj))
+ readonly = list_all_fields(inline)
```