Skip to content

272 dashboard create one endpoint for articles with proper status#357

Merged
salaun-marion merged 11 commits intodevelopfrom
272-dashboard-create-one-endpoint-for-articles-with-proper-status
Feb 26, 2026
Merged

272 dashboard create one endpoint for articles with proper status#357
salaun-marion merged 11 commits intodevelopfrom
272-dashboard-create-one-endpoint-for-articles-with-proper-status

Conversation

@eliselavy
Copy link
Collaborator

@salaun-marion

To test:

http://127.0.0.1:8000/api/articles/TqGQCFzXyreV/status/

pass in put:

  • {"status":"COPY_EDITING"}
    run github action pandoc.yml
    get the docx
    send to elisabeth.guerard need to be remove

or method added in the API

  • http://127.0.0.1:8000/api/articles/docx?pid=TqGQCFzXyreV

  • http://127.0.0.1:8000/api/articles/api/articles/docx/email?pid=TqGQCFzXyreV

  • {"status":"PUBLISHED"}
    add citation - controle DOI - publication date

@eliselavy eliselavy linked an issue Feb 20, 2026 that may be closed by this pull request
PUBLISHED = (
"PUBLISHED",
"Published",
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add SOCIAL_MEDIA and ARCHIVED.



def save_citation(article_id):
logger.info(f"save_article_citation:{article_id}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to write the name of the function, write instead 'save_citation', so that for debugging we know exactly what to look for :)

article = Article.objects.get(pk=article_id)
except Article.DoesNotExist:
logger.error(f"save_article_citation:{article_id} not found")
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe here do a raise Exception("Article id not found") instead of a return

@@ -1,10 +1,15 @@
#!/usr/bin/env python3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can rename the file github_action.py

#!/usr/bin/env python3
import logging
import os
import sys
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not forget to clean imports that we are not using :)

return Response(
{"error": f"repository_url is missing for PID '{pid}'."},
status=400,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the check of the article pid outside of the first try exept



def send_email_copy_editor(pid, docx_bytes):
COPY_EDITOR_ADDRESS = "elisabeth.guerard@uni.lu"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The email address should be stored as env variable. It should not be commited.


@api_view(["GET"])
@permission_classes([IsAdminUser])
def send_docx_email(request):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can merge that one with the following function because error response should be managed at the level of the endpoint function not after.


docx_bytes = fetch_docx_bytes(pid, branch_name)
send_email_copy_editor(pid, docx_bytes)
return Response({"status": "sent", "pid": pid})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it is a success we need to set the status at 200 with an informative message like :

return Response({"message": "Docx sent succesfully by email for article : {pid}"}, status=200)

def send_docx_email(request):
"""
Send the docx as an email attachment.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not hesitate to write endpoint path into the docstring:


    """
    GET api/articles/docx/email

    Send the docx as an email attachment.
    :params pid: the article PID
    :params branch_name: the branch name where the docx file is located, by default "pandoc"
    """

Then it is a bit more clear to what it corresponds :)

@salaun-marion
Copy link
Collaborator

salaun-marion commented Feb 26, 2026

To test:

http://127.0.0.1:8000/api/articles/TqGQCFzXyreV/status/

pass in put:

* `{"status":"COPY_EDITING"}`
  run github action pandoc.yml
  get the docx
  send to elisabeth.guerard need to be remove

or method added in the API

* `http://127.0.0.1:8000/api/articles/docx?pid=TqGQCFzXyreV`

* `http://127.0.0.1:8000/api/articles/api/articles/docx/email?pid=TqGQCFzXyreV`

* `{"status":"PUBLISHED"}`
  add citation - controle DOI - publication date

Main changes made :

  • remove the actions from the status handlers for copy editing
  • add doc strings everywhere
  • remove sensitive variables to .env
  • rename some functions/ misspelling

After changes, test done for :

  • change status through PATCH /api/articles/:pid/status endpoint with COPY_EDITING ✅ and PEER_REVIEW
  • send an email with the docx through POST /api/articles/docx/email endpoint with in the JSON body, the pid and body
  • get the docx document through GET /api/articles/docx endpoint with path parameter pid

Question

  • Do we need to have the send_docx_email function into the handler in case we still want to trigger the action from Django admin panel ?
  • Do we have a timestamp with the status change ? We need to think about the future log component where we should be able to have the list of the different status (see this github issue #809 ) (see here too [Article Status] SOCIAL_MEDIA #298)

@salaun-marion salaun-marion merged commit 796a02a into develop Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dashboard] Create one endpoint for /articles with proper status

2 participants