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 69aecc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 8 additions & 1 deletion lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ class Tender(models.Model):
"siae_email_link_click_or_detail_display_count",
"siae_detail_contact_click_count",
]
FIELDS_STATS_TIMESTAMPS = ["published_at", "validated_at", "sent_at", "siae_list_last_seen_date", "created_at", "updated_at"]
FIELDS_STATS_TIMESTAMPS = [
"published_at",
"validated_at",
"sent_at",
"siae_list_last_seen_date",
"created_at",
"updated_at",
]
FIELDS_STATS = FIELDS_STATS_COUNT + FIELDS_STATS_TIMESTAMPS + []
READONLY_FIELDS = FIELDS_SURVEY_TRANSACTIONED + FIELDS_STATS

Expand Down
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 69aecc9

Please sign in to comment.