Skip to content

Commit

Permalink
User readonly fields cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Dec 6, 2023
1 parent c861e43 commit c3f6869
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lemarche/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,14 @@ class UserAdmin(FieldsetsInlineMixin, UserAdmin):
autocomplete_fields = ["company", "partner_network"]
readonly_fields = (
[field.name for field in User._meta.fields if field.name.startswith("c4_")]
+ [f"{field}_last_updated" for field in User.TRACK_UPDATE_FIELDS]
+ [field.name for field in User._meta.fields if field.name.endswith("_last_seen_date")]
+ [field for field in User.READONLY_FIELDS]
+ [
"siae_count_annotated_with_link",
"tender_count_annotated_with_link",
"favorite_list_count_with_link",
"last_login",
"image_url",
"image_url_display",
"extra_data",
"created_at",
"updated_at",
]
)

Expand Down
12 changes: 12 additions & 0 deletions lemarche/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ class User(AbstractUser):
"api_key",
]

FIELDS_STATS_COUNT = ["favorite_list_count"]
FIELDS_STATS_TIMESTAMPS = [
"api_key_last_updated",
"dashboard_last_seen_date",
"tender_list_last_seen_date",
"date_joined",
"last_login",
"created_at",
"updated_at",
]
READONLY_FIELDS = FIELDS_STATS_COUNT + FIELDS_STATS_TIMESTAMPS

# used in templates
KIND_SIAE = user_constants.KIND_SIAE
KIND_BUYER = user_constants.KIND_BUYER
Expand Down

0 comments on commit c3f6869

Please sign in to comment.