Skip to content

258 allow to manage multiple documents #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

rnudb
Copy link
Contributor

@rnudb rnudb commented Jan 2, 2023

No description provided.

@rnudb rnudb linked an issue Jan 2, 2023 that may be closed by this pull request
@rnudb rnudb force-pushed the 258-allow-to-manage-multiple-documents branch 2 times, most recently from 6de2b54 to 081d8f2 Compare January 3, 2023 16:23
@rnudb rnudb marked this pull request as ready for review January 3, 2023 16:56
@rnudb rnudb force-pushed the 258-allow-to-manage-multiple-documents branch from 00ac2b3 to 03b78c3 Compare January 13, 2023 15:54
@rnudb rnudb force-pushed the 258-allow-to-manage-multiple-documents branch from 74438dc to 4f08bdf Compare January 25, 2023 15:31
@NathanFortyTwo NathanFortyTwo force-pushed the 258-allow-to-manage-multiple-documents branch from 4f08bdf to f7c3707 Compare October 23, 2024 08:25
@NathanFortyTwo
Copy link
Collaborator

Since we pass "CV" as document type in views::new_candidate_POST_handler

pyoupyou/interview/views.py

Lines 510 to 513 in 0801752

content = request.FILES.getlist("cv", [])
for file in content:
Document.objects.create(document_type="CV", content=file, candidate=candidate)

and in views::edit_candidate

pyoupyou/interview/views.py

Lines 911 to 915 in 0801752

content = request.FILES.getlist("cv", None)
print(content)
if content:
for doc in content:
Document.objects.create(document_type="CV", content=doc, candidate=candidate)

All documents uploaded to via the form on /candidate will be marked it as a 'CV' type
If the purpose of multiple fileUpload is to have both 'CV' and 'CL' (Cover Letter) attached to Candidate, maybe some more small modifications are needed, especially since the 'CL' DOCUMENT_TYPE is already handled :

class Document(models.Model):
DOCUMENT_TYPE = (("CV", "CV"), ("CL", "Cover Letter"), ("OT", "Others"))
created_date = models.DateTimeField(auto_now_add=True, verbose_name=_("Creation date"))
candidate = models.ForeignKey(Candidate, verbose_name=_("Candidate"), on_delete=models.CASCADE)
document_type = models.CharField(max_length=2, choices=DOCUMENT_TYPE, verbose_name=_("Kind of document"))
content = models.FileField(upload_to=document_path, verbose_name=_("Content file"))

@NathanFortyTwo NathanFortyTwo force-pushed the 258-allow-to-manage-multiple-documents branch from 73cb6d8 to 3dc5cae Compare October 25, 2024 07:59
@@ -36,7 +37,9 @@ class Meta:
helper = FormHelper()
exclude = ("anonymized", "anonymized_hashed_name", "anonymized_hashed_email")

cv = forms.FileField(label="CV (pour une candidature)", required=False)
candidate_documents = forms.FileField(
label="Documents (CV / Lettre de motivation / Autre)", required=False, widget=UploadFilesWidget()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Label need to be translatable, and the base value is in english

@@ -94,7 +94,9 @@ <h4> {% trans 'Process information' %}</h4>
<dd>
<ul>
{% for d in documents %}
<li> <a href="{{ d.content.url }}" > {{ d.document_type }}</a>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove blank lines

@@ -754,6 +755,104 @@ def setUp(self):
self.fake = faker.Faker()

self.tz = pytz.timezone("Europe/Paris")
seed = 72775
random.seed(seed)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need random => Rewrite test to avoid using it
Using random with a seed means we can write directly the random value, and it will be easier to readiness

pyoupyou/urls.py Outdated
@@ -60,6 +60,11 @@
views.delete_document_minute_ajax,
name="delete-document-minute",
),
re_path(
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to line break, character count < 120

@@ -261,6 +261,11 @@ def process(request, process_id, slug_info=None):
goal = last_itw.goal

documents = process.candidate.document_set.all()

doc_type_verbose_map = dict(Document.DOCUMENT_TYPE)
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 avoid it and use directly in template get_FOO_display
https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_display

@@ -730,6 +739,19 @@ def delete_document_minute_ajax(request):
return JsonResponse({})


@login_required
@require_http_methods(["POST"])
def delete_document_ajax(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'm not sure why we delete documents directly and not when we save the form. We can just mark them for deletion

@NathanFortyTwo NathanFortyTwo force-pushed the 258-allow-to-manage-multiple-documents branch from 826dd3b to aeeccc3 Compare October 28, 2024 10:47
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.

Allow to manage multiple documents
3 participants