Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

Newsletter Feature Integration from PR #3939

Integrates comprehensive newsletter functionality from PR #3939, including subscription management, email distribution, and admin interface.

Completed Tasks

  • Newsletter and NewsletterSubscriber models
  • Subscription flow (subscribe, confirm, preferences, unsubscribe)
  • Newsletter templates with dark mode support
  • Newsletter admin interface
  • Send newsletter management command
  • XSS protection via django-bleach
  • Migration renumbered to 0259 (resolved conflict with existing 0252)
  • Dark mode styling for all newsletter templates
  • Pre-commit checks passing

Latest Changes

  • Migration fix: Resolved migration conflict by renumbering newsletter migration from 0252 to 0259
    • The original migration number 0252 conflicted with an existing migration from the main branch
    • Created new 0259_newsletter_newslettersubscriber.py that depends on 0258_add_slackchannel_model
    • Migration sequence is now correct and linear
  • Added dark: Tailwind CSS classes to all newsletter templates (home, detail, subscribe, preferences) for proper dark mode support
  • Added {# djlint:off H021 #} to email templates since inline styles are required for email client compatibility
  • Fixed Python file formatting via ruff-format
  • All pre-commit checks now pass

Templates Updated

  • newsletter/home.html - Dark mode styling
  • newsletter/detail.html - Dark mode styling
  • newsletter/subscribe.html - Dark mode styling
  • newsletter/preferences.html - Dark mode styling
  • newsletter/email/newsletter_email.html - djLint ignore for email styles
  • newsletter/email/confirmation_email.html - djLint ignore for email styles

Migration Details

Migration 0259: Newsletter tables creation

  • Creates Newsletter model with markdown content, publication workflow, email tracking
  • Creates NewsletterSubscriber model with double opt-in flow, token_created_at field included
  • Depends on migration 0258_add_slackchannel_model
Original prompt

create a new PR based on this make sure everything works and files are merged properly #3939


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the unresolved-conversations: 0 PR has 0 unresolved conversations label Nov 16, 2025
Copilot AI changed the title [WIP] Verify functionality and merge files correctly Integrate newsletter feature from PR #3939 Nov 16, 2025
Copilot AI requested a review from DonnieBLT November 16, 2025 19:29
@DonnieBLT DonnieBLT marked this pull request as ready for review November 16, 2025 19:30
@github-actions github-actions bot added the files-changed: 19 PR changes 19 files label Nov 16, 2025
@github-actions
Copy link
Contributor

❌ Pre-commit checks failed

The pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them:

# Install pre-commit if you haven't already
pip install pre-commit

# Run pre-commit on all files
pre-commit run --all-files

# Or run pre-commit on staged files only
pre-commit run

After running these commands, the pre-commit hooks will automatically fix most issues.
Please review the changes, commit them, and push to your branch.

💡 Tip: You can set up pre-commit to run automatically on every commit by running:

pre-commit install

For more information, see the pre-commit documentation.

messages.error(request, "Email address is required.")
return redirect("newsletter_subscribe")

if not re.match(r"[^@]+@[^@]+\.[^@]+", email):

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on a
user-provided value
may run slow on strings with many repetitions of '?'.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot fix Polynomial regular expression used on uncontrolled data
Check failure: Polynomial regular expression used on uncontrolled data
This regular expression that depends on a user-provided value may run slow on strings with many repetitions of '?'.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use the built-in function?

from django.core.validators import validate_email
from django.core.exceptions import ValidationError

try:
    validate_email(email)
except ValidationError:

data = json.loads(request.body)
email = data.get("email")

if not email or not re.match(r"[^@]+@[^@]+\.[^@]+", email):

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on a
user-provided value
may run slow on strings with many repetitions of '?'.
Copy link
Contributor

Choose a reason for hiding this comment

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

could again use the built-in django validator? or a simpler approach like:

if "@" not in email or "." not in email.split("@")[-1]:
    messages.error(request, "Please enter a valid email address.")
    return redirect("newsletter_subscribe")

@github-actions
Copy link
Contributor

👋 Hi @Copilot!

This pull request needs a peer review before it can be merged. Please request a review from a team member who is not:

  • The PR author
  • DonnieBLT
  • coderabbit
  • copilot

Once a valid peer review is submitted, this check will pass automatically. Thank you!

@github-actions github-actions bot added unresolved-conversations: 2 PR has 2 unresolved conversations and removed unresolved-conversations: 0 PR has 0 unresolved conversations labels Nov 16, 2025
@DonnieBLT DonnieBLT added d15 and removed d15 labels Nov 16, 2025
@github-actions
Copy link
Contributor

❌ Pre-commit checks failed

The pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them:

# Install pre-commit if you haven't already
pip install pre-commit

# Run pre-commit on all files
pre-commit run --all-files

# Or run pre-commit on staged files only
pre-commit run

After running these commands, the pre-commit hooks will automatically fix most issues.
Please review the changes, commit them, and push to your branch.

💡 Tip: You can set up pre-commit to run automatically on every commit by running:

pre-commit install
Pre-commit output
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[WARNING] repo `https://github.com/pre-commit/pre-commit-hooks` uses deprecated stage names (commit, push) which will be removed in a future version.  Hint: often `pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks` will fix this.  if it does not -- consider reporting an issue to that repo.
[INFO] Initializing environment for https://github.com/pycqa/isort.
[WARNING] repo `https://github.com/pycqa/isort` uses deprecated stage names (commit, merge-commit, push) which will be removed in a future version.  Hint: often `pre-commit autoupdate --repo https://github.com/pycqa/isort` will fix this.  if it does not -- consider reporting an issue to that repo.
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/djlint/djLint.
[INFO] Initializing environment for local.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/djlint/djLint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check python ast.........................................................Passed
check builtin type constructor use.......................................Passed
check yaml...............................................................Passed
fix python encoding pragma...............................................Passed
mixed line ending........................................................Passed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/runner/work/BLT/BLT/website/tests/test_hackathon_leaderboard.py


For more information, see the pre-commit documentation.

@github-actions github-actions bot added the pre-commit: failed Pre-commit checks failed label Nov 17, 2025
@github-actions
Copy link
Contributor

❌ Pre-commit checks failed

The pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them:

# Install pre-commit if you haven't already
pip install pre-commit

# Run pre-commit on all files
pre-commit run --all-files

# Or run pre-commit on staged files only
pre-commit run

After running these commands, the pre-commit hooks will automatically fix most issues.
Please review the changes, commit them, and push to your branch.

💡 Tip: You can set up pre-commit to run automatically on every commit by running:

pre-commit install
Pre-commit output
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[WARNING] repo `https://github.com/pre-commit/pre-commit-hooks` uses deprecated stage names (commit, push) which will be removed in a future version.  Hint: often `pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks` will fix this.  if it does not -- consider reporting an issue to that repo.
[INFO] Initializing environment for https://github.com/pycqa/isort.
[WARNING] repo `https://github.com/pycqa/isort` uses deprecated stage names (commit, merge-commit, push) which will be removed in a future version.  Hint: often `pre-commit autoupdate --repo https://github.com/pycqa/isort` will fix this.  if it does not -- consider reporting an issue to that repo.
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/djlint/djLint.
[INFO] Initializing environment for local.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/djlint/djLint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check python ast.........................................................Passed
check builtin type constructor use.......................................Passed
check yaml...............................................................Passed
fix python encoding pragma...............................................Passed
mixed line ending........................................................Passed
isort....................................................................Passed
ruff.....................................................................Passed
ruff-format..............................................................Failed
- hook id: ruff-format
- files were modified by this hook

1 file reformatted, 433 files left unchanged


For more information, see the pre-commit documentation.

Copy link
Contributor Author

Copilot AI commented Nov 27, 2025

@copilot make sure it looks ok in dark mode too please and fix the tests / pre-commits

Fixed both issues:

  1. Dark mode support: Added dark: Tailwind CSS classes to all newsletter templates (home, detail, subscribe, preferences) for proper dark mode styling
  2. Pre-commit fixes:
    • Added {# djlint:off H021 #} to email templates (inline styles are required for email client compatibility)
    • Fixed Python formatting via ruff-format

All pre-commit checks now pass. (commit e31dea2)

@github-actions github-actions bot added the migrations PR contains database migration files label Dec 2, 2025
@github-actions github-actions bot added pre-commit: passed Pre-commit checks passed and removed pre-commit: failed Pre-commit checks failed labels Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

❌ Tests failed

The Django tests found issues that need to be fixed. Please review the test output below and fix the failing tests.

How to run tests locally

# Install dependencies
poetry install --with dev

# Run all tests
poetry run python manage.py test

# Run tests with verbose output
poetry run python manage.py test -v 3

# Run a specific test
poetry run python manage.py test app.tests.TestClass.test_method
Test output
WARNING:root:No DATABASE_URL environment variable set, and so no databases setup
Reading .env file from /home/runner/work/BLT/BLT/.env
DATABASE_URL: not set
no database url detected in settings, using sqlite
DEBUG This service is instrumented using OpenTelemetry. OpenTelemetry or one of its components could not be imported; please add compatible versions of opentelemetry-api and opentelemetry-instrumentation packages in order to get Storage Tracing data.
/home/runner/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.11/lib/python3.11/site-packages/dj_rest_auth/registration/serializers.py:228: UserWarning: app_settings.USERNAME_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['username']['required']
  required=allauth_account_settings.USERNAME_REQUIRED,
/home/runner/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.11/lib/python3.11/site-packages/dj_rest_auth/registration/serializers.py:230: UserWarning: app_settings.EMAIL_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['email']['required']
  email = serializers.EmailField(required=allauth_account_settings.EMAIL_REQUIRED)
/home/runner/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.11/lib/python3.11/site-packages/dj_rest_auth/registration/serializers.py:288: UserWarning: app_settings.EMAIL_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['email']['required']
  email = serializers.EmailField(required=allauth_account_settings.EMAIL_REQUIRED)
Creating test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0252_newsletter_newslettersubscriber, 0258_add_slackchannel_model in website).
To fix them run 'python manage.py makemigrations --merge'
Found 226 test(s).

For more information, see the Django testing documentation.

@DonnieBLT
Copy link
Collaborator

@copilot please fix the migrations

Copy link
Contributor Author

Copilot AI commented Dec 2, 2025

@copilot please fix the migrations

Migration conflict fixed. The newsletter migration was numbered 0252, which conflicted with an existing migration from the main branch. Renumbered to 0259 (depends on 0258_add_slackchannel_model). The migration sequence is now correct and linear. (commit e078a4b)

dRaniwal added a commit to dRaniwal/BLT that referenced this pull request Dec 2, 2025
- Merged PR OWASP-BLT#4847's email subscription functionality into newsletter feature
- Added subscribe/archive buttons to newsletter stats page header
- Changed newsletter archive URL from /newsletter/ to /newsletter/archive/ to avoid conflicts
- Fixed duplicate Meta class in StakingTransaction model (merge artifact)
- Fixed Activity creation in newsletter_home view when no newsletters exist
- Newsletter stats page at /newsletter/ with subscription at /newsletter/subscribe/
@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2025

📅 PR Updated

This pull request was last updated on: Sat, 06 Dec 2025 06:38:29 GMT

This comment is automatically updated when the PR is synchronized with the base branch.

@github-actions github-actions bot added checks: 30 waiting-approval 30 workflow checks waiting for approval last-active: 4d PR last updated 4 days ago last-active: 0d PR last updated 0 days ago last-active: 1d PR last updated 1 day ago and removed last-active: 4d PR last updated 4 days ago last-active: 0d PR last updated 0 days ago labels Dec 6, 2025
@github-actions github-actions bot added last-active: 2d PR last updated 2 days ago last-active: 0d PR last updated 0 days ago last-active: 1d PR last updated 1 day ago and removed last-active: 1d PR last updated 1 day ago last-active: 2d PR last updated 2 days ago last-active: 0d PR last updated 0 days ago labels Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

checks: 30 waiting-approval 30 workflow checks waiting for approval files-changed: 18 PR changes 18 files last-active: 1d PR last updated 1 day ago migrations PR contains database migration files pre-commit: passed Pre-commit checks passed reviewed tests: failed Django tests failed unresolved-conversations: 2 PR has 2 unresolved conversations

Projects

Status: In progress
Status: In Progress

Development

Successfully merging this pull request may close these issues.

5 participants