138 lines
4.5 KiB
Markdown
138 lines
4.5 KiB
Markdown
# Prompt 004: HR Email Notifications and Application Review Page
|
|||
|
|
|
||
|
|
## Objective
|
||
|
|
Implement HR email notifications when an application is submitted and create a review page where HR can view complete application details and download attachments.
|
||
|
|
|
||
|
|
## Requirements
|
||
|
|
|
||
|
|
### 1. HR Email Notification
|
||
|
|
- When user submits application on page 4 (submit_application route), send email to HR
|
||
|
|
- HR email address configurable via environment variable `HR_EMAIL`
|
||
|
|
- Email should be in German
|
||
|
|
- Email should include:
|
||
|
|
- Job position name
|
||
|
|
- Applicant's name and email
|
||
|
|
- Submission timestamp
|
||
|
|
- Direct link to application review page: `http://yourdomain.com/application/<session_id>/`
|
||
|
|
- Brief summary (e.g., number of documents uploaded)
|
||
|
|
|
||
|
|
### 2. Application Review Page Route
|
||
|
|
- Create new route: `/application/<session_id>/`
|
||
|
|
- No additional authentication needed (session ID provides security through obscurity)
|
||
|
|
- Display all application information in a clean, readable format
|
||
|
|
- Show all uploaded files with download links
|
||
|
|
|
||
|
|
### 3. Application Review Template
|
||
|
|
- Create `templates/application_view.html`
|
||
|
|
- Display in German:
|
||
|
|
- Job position
|
||
|
|
- Personal information (all fields from page 2)
|
||
|
|
- Motivation answers (all fields from page 3)
|
||
|
|
- List of uploaded documents with:
|
||
|
|
- Original filename
|
||
|
|
- File size
|
||
|
|
- Download link for each file
|
||
|
|
- Submission timestamp
|
||
|
|
- Email address used for application
|
||
|
|
|
||
|
|
### 4. File Download Route
|
||
|
|
- Create route: `/application/<session_id>/download/<filename>`
|
||
|
|
- Serve the actual uploaded file
|
||
|
|
- Use `send_from_directory` with proper security checks
|
||
|
|
- Verify filename exists in application's uploaded_files list
|
||
|
|
|
||
|
|
### 5. Configuration Updates
|
||
|
|
- Add `HR_EMAIL` to `config.py` with environment variable
|
||
|
|
- Add `HR_EMAIL` to `.env.example`
|
||
|
|
- Add `APPLICATION_URL_BASE` to config for constructing full URLs in emails
|
||
|
|
|
||
|
|
### 6. Error Handling
|
||
|
|
- Handle missing application gracefully (404 error)
|
||
|
|
- Handle missing files gracefully (404 error)
|
||
|
|
- Validate session_id format
|
||
|
|
|
||
|
|
### 7. Testing Requirements
|
||
|
|
- Test HR email is sent on application submission
|
||
|
|
- Test email contains correct information and link
|
||
|
|
- Test application review page displays all data correctly
|
||
|
|
- Test file download works
|
||
|
|
- Test error cases (invalid session_id, missing files)
|
||
|
|
- Test that HR email is not sent if email sending fails
|
||
|
|
|
||
|
|
## Technical Implementation Notes
|
||
|
|
|
||
|
|
### Email Template (German)
|
||
|
|
```
|
||
|
|
Betreff: Neue Bewerbung eingegangen: {job_name}
|
||
|
|
|
||
|
|
Sehr geehrtes HR-Team,
|
||
|
|
|
||
|
|
es ist eine neue Bewerbung eingegangen:
|
||
|
|
|
||
|
|
Position: {job_name}
|
||
|
|
Name: {firstname} {name}
|
||
|
|
E-Mail: {email}
|
||
|
|
Eingereicht am: {timestamp}
|
||
|
|
Anzahl der hochgeladenen Dokumente: {file_count}
|
||
|
|
|
||
|
|
Sie können die vollständige Bewerbung hier einsehen:
|
||
|
|
{application_url}
|
||
|
|
|
||
|
|
Mit freundlichen Grüßen,
|
||
|
|
Ihr Bewerbungssystem
|
||
|
|
```
|
||
|
|
|
||
|
|
### File Storage Structure
|
||
|
|
Files are already stored in: `applications/<session_id>/files/<stored_filename>`
|
||
|
|
The stored_filename is in the uploaded_files list in the YAML data.
|
||
|
|
|
||
|
|
### Security Considerations
|
||
|
|
- Session IDs are UUIDs (sufficiently random and unguessable)
|
||
|
|
- Only allow downloading files that are listed in the application's uploaded_files
|
||
|
|
- Use `secure_filename()` when handling file operations
|
||
|
|
- No directory traversal attacks (verify file is in correct session folder)
|
||
|
|
|
||
|
|
## Files to Modify
|
||
|
|
|
||
|
|
1. **config.py**
|
||
|
|
- Add HR_EMAIL configuration
|
||
|
|
- Add APPLICATION_URL_BASE configuration
|
||
|
|
|
||
|
|
2. **.env.example**
|
||
|
|
- Add HR_EMAIL example
|
||
|
|
- Add APPLICATION_URL_BASE example
|
||
|
|
|
||
|
|
3. **app.py**
|
||
|
|
- Modify `submit_application` route to send HR email
|
||
|
|
- Add new route: `view_application(session_id)`
|
||
|
|
- Add new route: `download_file(session_id, filename)`
|
||
|
|
- Add email helper function for HR notification
|
||
|
|
|
||
|
|
4. **templates/application_view.html** (NEW)
|
||
|
|
- Create clean layout for HR to review application
|
||
|
|
- Display all fields in German
|
||
|
|
- Provide download links for attachments
|
||
|
|
|
||
|
|
## Files to Create (Tests)
|
||
|
|
|
||
|
|
1. **tests/test_hr_notifications.py** (NEW)
|
||
|
|
- Test HR email is sent on submission
|
||
|
|
- Test email content is correct
|
||
|
|
- Test email contains proper link
|
||
|
|
|
||
|
|
2. **tests/test_application_view.py** (NEW)
|
||
|
|
- Test application view page renders correctly
|
||
|
|
- Test all data is displayed
|
||
|
|
- Test file download works
|
||
|
|
- Test 404 for invalid session_id
|
||
|
|
- Test 404 for invalid filename
|
||
|
|
|
||
|
|
## Success Criteria
|
||
|
|
- HR receives email when application is submitted
|
||
|
|
- Email contains all required information in German
|
||
|
|
- Application review page displays all application data
|
||
|
|
- HR can download all uploaded files
|
||
|
|
- All existing tests still pass
|
||
|
|
- New tests achieve high coverage for new functionality
|
||
|
|
- No security vulnerabilities introduced
|