Skip to content

Commit

Permalink
Fix des bugs de dépôts de besoins (#582)
Browse files Browse the repository at this point in the history
* fix author and status in admin

* fix cmp error on tracking

* try csrf fix
  • Loading branch information
madjid-asa committed Dec 20, 2022
1 parent 0087db1 commit 9621b6e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
8 changes: 4 additions & 4 deletions config/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"bitoubi-django.cleverapps.io",
]

CSRF_TRUSTED_ORIGINS = [
"https://*.inclusion.beta.gouv.fr",
"https://bitoubi-django.cleverapps.io",
]
# CSRF_TRUSTED_ORIGINS = [
# "https://*.inclusion.beta.gouv.fr",
# "https://bitoubi-django.cleverapps.io",
# ]


SECURE_SSL_REDIRECT = env.str("SECURE_SSL_REDIRECT", True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def enrich_download_list(self, download_list):
}
)
# user
user_id = tracker_meta_data["user_id"]
user_id = tracker_meta_data.get("user_id")
user_dict = next((user for user in user_list if user["id"] == user_id), {})
download_item.update(
{
Expand All @@ -127,7 +127,7 @@ def enrich_download_list(self, download_list):
# other
download_item.update(
{
"cmp": tracker_meta_data["cmp"],
"cmp": tracker_meta_data.get("cmp", ""),
"timestamp": item.date_created,
"stats_id": item.id_internal,
}
Expand Down
4 changes: 2 additions & 2 deletions lemarche/stats/management/commands/export_user_search_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def enrich_search_list(self, search_list):
}
)
# user
user_id = tracker_meta_data["user_id"]
user_id = tracker_meta_data.get("user_id")
user_dict = next((user for user in user_list if user["id"] == user_id), {})
search_item.update(
{
Expand All @@ -127,7 +127,7 @@ def enrich_search_list(self, search_list):
# other
search_item.update(
{
"cmp": tracker_meta_data["cmp"],
"cmp": tracker_meta_data.get("cmp"),
"timestamp": item.date_created,
"stats_id": item.id_internal,
}
Expand Down
13 changes: 12 additions & 1 deletion lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class TenderAdmin(admin.ModelAdmin):
"siae_detail_display_count_with_link",
"siae_detail_contact_click_count_with_link",
"extra_data_prettier",
"status",
"logs_display",
"created_at",
"updated_at",
Expand Down Expand Up @@ -219,6 +218,18 @@ def lookup_allowed(self, lookup, *args, **kwargs):
return True
return super().lookup_allowed(lookup, *args, **kwargs)

def get_readonly_fields(self, request, obj=None):
readonly_fields = list(self.readonly_fields)
if obj.author_id and obj.author_id != request.user.id:
# add status in read only when the tender is not owned by the current user
readonly_fields.append("status")
return readonly_fields

def save_model(self, request, obj: Tender, form, change):
if not obj.id and not obj.author_id:
obj.author = request.user
super().save_model(request, obj, form, change)

def is_validate(self, tender: Tender):
return tender.validated_at is not None

Expand Down

0 comments on commit 9621b6e

Please sign in to comment.