Skip to content

Same question fix#2

Open
op2adi wants to merge 22 commits intomainfrom
same-question-fix
Open

Same question fix#2
op2adi wants to merge 22 commits intomainfrom
same-question-fix

Conversation

@op2adi
Copy link
Copy Markdown
Collaborator

@op2adi op2adi commented May 5, 2025

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Django “MediBot” app UX and reporting features by adding a dedicated PDF download endpoint for reports, introducing an About page route/template, updating admin UI links, and adding a GitHub Actions CI workflow. It also attempts to clean up repo artifacts (bytecode) and adjusts dependency files.

Changes:

  • Add a doctor-only PDF download endpoint for generated reports and wire it into the report detail page + URLs.
  • Add an About page (route + template) and update site navigation/admin index links.
  • Add GitHub Actions CI workflow and update .gitignore to ignore Python bytecode artifacts.

Reviewed changes

Copilot reviewed 21 out of 134 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
Merilife/MediBot/requirements.txt Replaces a large pinned dependency list with a minimal set of packages.
Merilife/MediBot/chatbot-website/reports/views.py Adds download_report_pdf and removes inline PDF blob serving from view_report.
Merilife/MediBot/chatbot-website/reports/urls.py Adds route for downloading report PDFs.
Merilife/MediBot/chatbot-website/reports/templates/reports/report_detail.html Adds “Download PDF” button and adjusts doctor/patient action area.
Merilife/MediBot/chatbot-website/reports/migrations/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/migrations/pycache/0004_report_pdf_blob.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/migrations/pycache/0003_report_treatment.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/migrations/pycache/0002_report_assigned_doctor_report_user.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/migrations/pycache/0001_initial.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/pycache/views.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/pycache/urls.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/pycache/models.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/pycache/apps.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/pycache/admin.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/reports/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/meditron/pycache/utils.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/meditron/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/media/test/reports_text/adipaadipa.txt Removes test media content file.
Merilife/MediBot/chatbot-website/media/reports_text/adipaadipa.txt Removes media content file.
Merilife/MediBot/chatbot-website/chatbot_website/templatetags/pycache/load_tags.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/templatetags/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/settings.py Updates DB password in settings.
Merilife/MediBot/chatbot-website/chatbot_website/pycache/wsgi.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/urls.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/settings.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/models.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/load_views.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/load_middleware.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/load_manager.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/apps.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/admin.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot_website/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/urls.py Adds about/ route and imports about view.
Merilife/MediBot/chatbot-website/chatbot/tests/test_reports.py Updates PDF/report tests to use text_to_pdf and _generate_report directly.
Merilife/MediBot/chatbot-website/chatbot/tests/test_ai.py Adds a live Google GenAI API call test and embeds an API key.
Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/report_gen.html Disables input controls after report completion keywords are detected.
Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/medical_chat.html Adds language selection modal, updated layout, speech recognition changes, and chat-disable behavior.
Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/index.html Updates About link and adds admin-only “Register Doctor”; removes inline JS handler for start button.
Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/about.html Adds About page template with a profile image reference.
Merilife/MediBot/chatbot-website/chatbot/templates/admin/index.html Adds “Register New Doctor” link for superusers.
Merilife/MediBot/chatbot-website/chatbot/static/images/adi.png Adds a static image asset.
Merilife/MediBot/chatbot-website/chatbot/static/images Removes placeholder file that previously occupied the images path.
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0009_fix_migration_conflicts.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0008_alter_customuser_email.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0007_customuser_address_customuser_age_and_more.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0006_treatment_reqd.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0005_treatment.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0004_doctorprofile_patientprofile.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0002_customuser_groups_customuser_is_superuser_and_more.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/migrations/pycache/0001_initial.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/admin.py Adds DoctorProfile inline and updates specialization display/filtering/search in admin.
Merilife/MediBot/chatbot-website/chatbot/pycache/utils.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/urls.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/models.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/middleware.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/load_utils.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/backends.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/apps.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/ai_wrapper.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/admin.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/chatbot-website/chatbot/pycache/init.cpython-311.pyc Bytecode artifact added (should not be committed).
Merilife/MediBot/.gitignore Adds ignore rules for __pycache__/ and *.py[cod].
.github/workflows/ci.yml Adds Windows-based GitHub Actions workflow running installs, migrations, and pytest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +29 to +37
def test_google_genai_api_message(self):
try:
import google.generativeai as genai
genai.configure(api_key="AIzaSyB0R26JpwnrxR1iHP7SRdlXImYhG2NAYLQ")
model = genai.GenerativeModel('gemini-2.0-flash')
response = model.generate_content("Hello, are you working?")
assert hasattr(response, 'text') and response.text
except Exception as e:
assert False, f"Google GenAI API call failed: {e}" No newline at end of file
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This test embeds a real Google GenAI API key and makes a live external network call. This leaks credentials and will be flaky/non-deterministic in CI. Replace this with a mocked client (similar to test_genai_integration) and load any keys from secrets/env in runtime code, not tests.

Copilot uses AI. Check for mistakes.
Comment on lines 55 to +61
{% if request.user.doctor_profile %}
<a href="{% url 'doctor_dashboard' %}" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Dashboard
</a>
{% if request.user.doctor_profile and report.assigned_doctor == request.user %}
<a href="{% url 'download_report_pdf' report.id %}" class="btn btn-primary ml-2">
<i class="fas fa-file-download"></i> Download PDF
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Accessing request.user.doctor_profile directly in a template can raise RelatedObjectDoesNotExist for non-doctor users, which would break report viewing for patients. Use a safe check (e.g., pass an is_doctor boolean from the view, or check hasattr(request.user, 'doctor_profile') via a custom template filter/tag) before referencing the related object.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +33
<div class="about-container">
<h2>About Me</h2>
<img src="{% static 'images/aditya.png' %}" alt="Aditya Upadhyay">
<p>My name is Aditya Upadhyay, a passionate and dedicated student currently pursuing my degree from IIIT Delhi. I have a strong foundation in computer science and an avid interest in software development, algorithms, and data structures. My coding skills span across languages like C, C++, Python, and I am comfortable working with tools like Git, NumPy, pandas, and Matplotlib.</p>
<p>I have successfully contributed to various academic and personal projects involving image processing, data analysis, and machine learning. I actively participate in hackathons, coding competitions, and have consistently ranked among top performers in programming contests. My accomplishments include completing internships, volunteering for NGOs, and making meaningful contributions to open-source projects.</p>
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The About page references static 'images/aditya.png', but the static image added in this PR is images/adi.png. This will result in a broken image link. Update the template to match the actual filename (or rename the asset to aditya.png).

Copilot uses AI. Check for mistakes.
Comment on lines 188 to 193
<main>
<section id="introduction">
<h2>Your Personal Health Companion</h2>
<p>Experience seamless healthcare management with our intelligent chatbot assistant. Get personalized medical guidance, appointment scheduling, and health tracking all in one place.</p>
<button id="start-chat">Start Health Check</button>
</section>
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The Start Health Check button no longer has any handler/URL after the inline script was removed, so clicking it won't navigate anywhere. Either wrap it in an <a href="{% url 'chat' %}"> / form, or re-add a JS handler (preferably in a static JS file).

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +42
# Test _generate_report with dummy request and history
from chatbot.views.views import _generate_report
factory = RequestFactory()
request = factory.get('/')
history = "Q1: What are your main symptoms?\nA1: cold"
report, diagnosis, specialization = _generate_report(history, request)
assert 'report' in report.lower() or 'cold' in report.lower()
assert isinstance(diagnosis, str)
assert isinstance(specialization, str)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This test calls _generate_report(...), which triggers a real GenAI request via report_model.generate_content(...) in production code. That makes the test suite dependent on network availability and external API behavior. Please mock the model call (e.g., patch chatbot.views.views.report_model.generate_content) and assert on the parsing/handling logic instead.

Copilot uses AI. Check for mistakes.
Comment on lines 13 to +16
'ENGINE': 'django.db.backends.mysql',
'NAME': 'medico_db', # Change this to your actual database name
'USER': 'root', # MySQL username (usually 'root' for local development)this
'PASSWORD': 'harsh0604',
'PASSWORD': 'Aditya@1998',
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Database credentials are hardcoded in settings.py (and this commit changes them). This is a secret-management risk and will also make CI/local setup brittle. Please move the password (and ideally the whole DB config) to environment variables (e.g., via django-environ) and ensure no real credentials are committed.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
Comment on lines +31 to +34
- name: Run migrations
run: python manage.py migrate --noinput
working-directory: Merilife/MediBot/chatbot-website

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The CI workflow runs manage.py migrate but the project settings use MySQL by default. Since this workflow doesn't provision MySQL (or set env vars to switch to sqlite), this step is very likely to fail. Consider configuring a DB service (MySQL) + secrets, or switching CI to sqlite/test settings and letting pytest-django manage migrations/db setup (often you can drop the explicit migrate step).

Suggested change
- name: Run migrations
run: python manage.py migrate --noinput
working-directory: Merilife/MediBot/chatbot-website

Copilot uses AI. Check for mistakes.
Comment on lines +257 to +264
let message = $('<div>').addClass('message '+cls);

if (cls === 'bot' && text.includes('specialization')) {
message.addClass('specialization');
message.html(`<strong>${text}</strong>`);
} else {
message.text(text);
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

addMessage() uses message.html(...) for bot messages, inserting unsanitized model/AI output into the DOM. If the bot response contains HTML/JS, this becomes an XSS vector. Prefer text() (or sanitize/escape the string) and only inject trusted markup.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +9
# Python byte‑code
__pycache__/
*.py[cod]
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This .gitignore update is good, but the PR still includes many tracked __pycache__/ and *.pyc files. Those artifacts shouldn't be committed—please remove them from the repository (git rm --cached), so the ignore rules can take effect and the repo stays clean.

Copilot uses AI. Check for mistakes.
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.

4 participants