-
Notifications
You must be signed in to change notification settings - Fork 27
Admin notification system for image upload. #53
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
base: dev
Are you sure you want to change the base?
Admin notification system for image upload. #53
Conversation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary of ChangesHello @Pragnasri-363, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the application's administrative capabilities by integrating a new notification system. Administrators will now receive immediate alerts when images are uploaded, complete with an unread count and an intuitive interface to view and manage these notifications. The changes also lay down a more structured Flask application foundation, incorporating database migrations and a clear separation of concerns for models and views, thereby improving maintainability and scalability. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR introduces a notification system for admin users when new images are uploaded. The implementation is a good start, but there are several critical security vulnerabilities that must be addressed, primarily related to hardcoded secrets (database credentials, secret key, admin API key). These secrets are exposed in the source code, including in client-side JavaScript, which is a major risk.
Additionally, there are opportunities to improve code quality and maintainability by refactoring database transactions to be atomic, using existing helper methods to avoid code duplication, and following best practices for configuration and project structure. The frontend templates also have some issues, including invalid HTML and areas for UX and accessibility improvements. Finally, the documentation and dependency management can be improved for better clarity and reproducibility.
templates/admin.html
Outdated
| </div> | ||
|
|
||
| <script> | ||
| const ADMIN_HEADERS = { "X-ADMIN-KEY": "dev-admin" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The admin API key is hardcoded in the client-side JavaScript. This is a critical security vulnerability as it exposes the key to anyone who can view the page source. This key should never be exposed on the client side. Admin actions should be protected by a server-side session-based authentication mechanism (e.g., a login form for admins).
templates/index.html
Outdated
| </head> | ||
|
|
||
| <body> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
templates/gallery.html
Outdated
|
|
||
| {% for entry in entries %} | ||
| <div class="entry-card"> | ||
| <img src="{{ url_for('static', filename='uploads/' + entry.image_name) }}" alt="Patient Image"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alt text for the image is generic. For better accessibility, especially for users with screen readers, the alt text should be more descriptive. For example, it could include the patient's name.
<img src="{{ url_for('static', filename='uploads/' + entry.image_name) }}" alt="Image for patient {{ entry.patient_name }}">
templates/upload.html
Outdated
|
|
||
| fileInput.addEventListener("change", function () { | ||
| const file = this.files[0]; | ||
| const maxSize = 3* 1024 * 1024; // 3MB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
templates/upload.html
Outdated
| const maxSize = 3* 1024 * 1024; // 3MB | ||
|
|
||
| if (file && file.size > maxSize) { | ||
| alert("Image size must be less than 3MB"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This PR adds admin notification system which gets triggered when an image is uploaded.
Admin-notification system features :
Testing
Tested locally by uploading images and verifying notifications appear correctly.
Screenshots
Admin Dashboard – Notifications (With uploads)
Admin Dashboard – Notifications (After marked as seen)