Skip to content

Announcements - Platform-wide announcements added - #2647

Merged
Didayolo merged 2 commits into
developfrom
site_wise_announcements
Oct 20, 2026
Merged

Didayolo merged 2 commits into
developfrom
site_wise_announcements

Conversation

@ihsaan-ullah

@ihsaan-ullah ihsaan-ullah commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Add platform wide announcements shown in a banner above the header

  • Announcements can now be placed on the home page only or on all pages
  • All pages announcements show as a thin colored banner above the header on every page
  • Home page shows only its own announcements
  • Placement added to the announcements admin
  • Tests for home page and platform announcements

NOTE

This should be merged after #2621 because this is a checkbout from home_page_redesign branch

Screenshots

Single critical announcement on home page
Screenshot 2026-10-09 at 11 23 45 PM

Single critical announcement on other page
Screenshot 2026-10-09 at 11 23 53 PM

2 announcements
Screenshot 2026-10-09 at 11 24 10 PM

3 announcements
Screenshot 2026-10-09 at 11 24 30 PM

Issues this PR resolves

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

@ihsaan-ullah ihsaan-ullah changed the title [New Feature] Site wise announcements [New Feature] Platform announcements Oct 9, 2026
@ihsaan-ullah ihsaan-ullah changed the title [New Feature] Platform announcements Announcements - Platform-wide announcements aded Oct 10, 2026
@ObadaS

ObadaS commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Would it be possible to a third option that selects both ?
image

This would be better than duplicating an announcement twice (maintenance notice, queue problems etc, that we want to add on the home page and as a banner for everyone)

Also, an option for people to close the site-wide banner

@ihsaan-ullah

Copy link
Copy Markdown
Collaborator Author

With the new update, now users can see one announcement at the same time in home page and on other pages.

Screenshot 2026-10-17 at 3 55 31 PM

On django admin, you can select this option to show it at both places:
Screenshot 2026-10-17 at 3 57 41 PM

@ObadaS

ObadaS commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

I have merged the redesign then rebased this branch. However, I am getting an error when trying to add a home page and all pages announcement :

2026-10-20 10:28:23.411 | ERROR    | django.utils.log:log_response:253 - Internal Server Error: /admin/announcements/announcement/add/
Traceback (most recent call last):

  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           │    │      │       │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
           │    │      │       └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
           │    │      └ <method 'execute' of 'psycopg2.extensions.cursor' objects>
           │    └ <cursor object at 0x711848e049a0; closed: -1>
           └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>

psycopg2.errors.StringDataRightTruncation: value too long for type character varying(20)



The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/threading.py", line 1015, in _bootstrap
    self._bootstrap_inner()
    │    └ <function Thread._bootstrap_inner at 0x71184fe17920>
    └ <Thread(asyncio_0, started 124349079893696)>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/threading.py", line 1044, in _bootstrap_inner
    self.run()
    │    └ <function Thread.run at 0x71184fe176a0>
    └ <Thread(asyncio_0, started 124349079893696)>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/threading.py", line 995, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {}
    │    │        │    │        └ <Thread(asyncio_0, started 124349079893696)>
    │    │        │    └ (<weakref at 0x7118463af510; to 'concurrent.futures.thread.ThreadPoolExecutor' at 0x7118463963f0>, <_queue.SimpleQueue object...
    │    │        └ <Thread(asyncio_0, started 124349079893696)>
    │    └ <function _worker at 0x71184f4e04a0>
    └ <Thread(asyncio_0, started 124349079893696)>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/concurrent/futures/thread.py", line 93, in _worker
    work_item.run()
    │         └ <function _WorkItem.run at 0x71184f4e05e0>
    └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             │    │   │    │       │    └ {}
             │    │   │    │       └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
             │    │   │    └ ()
             │    │   └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
             │    └ functools.partial(<bound method SyncToAsync.thread_handler of <asgiref.sync.SyncToAsync object at 0x711846e158b0>>, <_UnixSel...
             └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
> File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 577, in thread_handler
    raise exc_info[1]
          └ (<class 'django.db.utils.DataError'>, DataError('value too long for type character varying(20)\n'), <traceback object at 0x71...
  File "/.venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
                     │            └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
                     └ <bound method BaseHandler._get_response_async of <django.core.handlers.asgi.ASGIHandler object at 0x711848fb96a0>>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 577, in thread_handler
    raise exc_info[1]
          └ (<class 'django.db.utils.DataError'>, DataError('value too long for type character varying(20)\n'), <traceback object at 0x71...
  File "/.venv/lib/python3.13/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
                     └ <asgiref.sync.SyncToAsync object at 0x7118461399a0>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 526, in __call__
    ret = await asyncio.shield(exec_coro)
                │       │      └ <Future finished exception=DataError('value too long for type character varying(20)\n')>
                │       └ <function shield at 0x71184f599620>
                └ <module 'asyncio' from '/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/asyncio/__init__.py'>
  File "/.venv/lib/python3.13/site-packages/asgiref/current_thread_executor.py", line 35, in run
    result = self.fn(*self.args, **self.kwargs)
             │        │            └ None
             │        └ None
             └ None
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 581, in thread_handler
    return func(*args, **kwargs)
           │     │       └ {}
           │     └ (functools.partial(<function ModelAdmin.add_view at 0x711847b967a0>, <ASGIRequest: POST '/admin/announcements/announcement/ad...
           └ <function SyncToAsync.__call__.<locals>.func at 0x711846127a60>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 508, in func
    return context.run(run_child)
           │       │   └ <function SyncToAsync.__call__.<locals>.func.<locals>.run_child at 0x711846126ac0>
           │       └ <method 'run' of '_contextvars.Context' objects>
           └ <_contextvars.Context object at 0x711847bbbdc0>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 506, in run_child
    return child()
           └ functools.partial(<function ModelAdmin.add_view at 0x711847b967a0>, <ASGIRequest: POST '/admin/announcements/announcement/add...
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 720, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
           │    │          │          │      │       └ {}
           │    │          │          │      └ (<ASGIRequest: POST '/admin/announcements/announcement/add/'>,)
           │    │          │          └ <bound method ModelAdmin.add_view of <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>>
           │    │          └ <function AdminSite.admin_view at 0x71184e4baf20>
           │    └ AdminSite(name='admin')
           └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 192, in _view_wrapper
    result = _process_exception(request, e)
             │                  └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
             └ <function make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception at 0x711846126840>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 190, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               │         │         │       └ {}
               │         │         └ ()
               │         └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
               └ <function AdminSite.admin_view.<locals>.inner at 0x7118461268e0>
  File "/.venv/lib/python3.13/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               │         │         │       └ {}
               │         │         └ ()
               │         └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
               └ <function AdminSite.admin_view.<locals>.inner at 0x711846126980>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/sites.py", line 246, in inner
    return view(request, *args, **kwargs)
           │    │         │       └ {}
           │    │         └ ()
           │    └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
           └ <bound method ModelAdmin.add_view of <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1985, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
           │    │               │              │         └ None
           │    │               │              └ ''
           │    │               └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
           │    └ <function ModelAdmin.changeform_view at 0x71184e4a8540>
           └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
           │             │       └ {}
           │             └ (<ASGIRequest: POST '/admin/announcements/announcement/add/'>, None, '', None)
           └ <function ModelAdmin.changeform_view at 0x711846126480>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 192, in _view_wrapper
    result = _process_exception(request, e)
             │                  └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
             └ <function make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception at 0x7118461265c0>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 190, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               │         │         │       └ {}
               │         │         └ (None, '', None)
               │         └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
               └ functools.partial(<bound method ModelAdmin.changeform_view of <AnnouncementExpansion: model=Announcement site=AdminSite(name=...
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1844, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
           │    │                │        │          │         └ None
           │    │                │        │          └ ''
           │    │                │        └ None
           │    │                └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
           │    └ <function ModelAdmin._changeform_view at 0x71184e4a8860>
           └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1895, in _changeform_view
    self.save_model(request, new_object, form, not add)
    │    │          │        │           │         └ True
    │    │          │        │           └ <AnnouncementForm bound=True, valid=True, fields=(title;level;placement;text;is_active;priority)>
    │    │          │        └ <Announcement: MAIN>
    │    │          └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
    │    └ <function ModelAdmin.save_model at 0x71184e4a7920>
    └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1315, in save_model
    obj.save()
    │   └ <function Model.save at 0x71184eccf9c0>
    └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
    │    └ <function Model.save_base at 0x71184eccfba0>
    └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 1008, in save_base
    updated = self._save_table(
              │    └ <function Model._save_table at 0x71184eccfce0>
              └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 1169, in _save_table
    results = self._do_insert(
              │    └ <function Model._do_insert at 0x71184eccfe20>
              └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 1210, in _do_insert
    return manager._insert(
           │       └ <function QuerySet._insert at 0x71184ee58360>
           └ <django.db.models.manager.Manager object at 0x711846398c50>
  File "/.venv/lib/python3.13/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
                   │    │               │      │       └ {'fields': [<django.db.models.fields.CharField: title>, <django.db.models.fields.TextField: text>, <django.db.models.fields.C...
                   │    │               │      └ ([<Announcement: MAIN>],)
                   │    │               └ '_insert'
                   │    └ <function BaseManager.get_queryset at 0x71184ee58040>
                   └ <django.db.models.manager.Manager object at 0x711846398c50>
  File "/.venv/lib/python3.13/site-packages/django/db/models/query.py", line 1873, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           │     │                  │                  └ [<django.db.models.fields.BigAutoField: id>]
           │     │                  └ 'default'
           │     └ <function Query.get_compiler at 0x71184edd3f60>
           └ <django.db.models.sql.subqueries.InsertQuery object at 0x7118463b79b0>
  File "/.venv/lib/python3.13/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql
    cursor.execute(sql, params)
    │      │       │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
    │      │       └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
    │      └ <function CursorDebugWrapper.execute at 0x71184ef694e0>
    └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 122, in execute
    return super().execute(sql, params)
                           │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
                           └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           │    └ <function CursorWrapper._execute_with_wrappers at 0x71184ef69300>
           └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           │        │    │       │     └ {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.postgresql.base.CursorDeb...
           │        │    │       └ False
           │        │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
           │        └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
           └ <bound method CursorWrapper._execute of <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>>
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
         │    │  └ <django.db.utils.DatabaseErrorWrapper object at 0x7118463acf50>
         │    └ <DatabaseWrapper vendor='postgresql' alias='default'>
         └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>
  File "/.venv/lib/python3.13/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
          │            │              │               └ StringDataRightTruncation('value too long for type character varying(20)\n')
          │            │              └ <traceback object at 0x711845066a00>
          │            └ <method 'with_traceback' of 'BaseException' objects>
          └ DataError('value too long for type character varying(20)\n')
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           │    │      │       │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
           │    │      │       └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
           │    │      └ <method 'execute' of 'psycopg2.extensions.cursor' objects>
           │    └ <cursor object at 0x711848e049a0; closed: -1>
           └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>

django.db.utils.DataError: value too long for type character varying(20)

2026-10-20 10:28:23.413 | ERROR    | django.utils.log:log_response:253 - Internal Server Error: /admin/announcements/announcement/add/
Traceback (most recent call last):

  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           │    │      │       │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
           │    │      │       └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
           │    │      └ <method 'execute' of 'psycopg2.extensions.cursor' objects>
           │    └ <cursor object at 0x711848e049a0; closed: -1>
           └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>

psycopg2.errors.StringDataRightTruncation: value too long for type character varying(20)



The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/threading.py", line 1015, in _bootstrap
    self._bootstrap_inner()
    │    └ <function Thread._bootstrap_inner at 0x71184fe17920>
    └ <Thread(asyncio_0, started 124349079893696)>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/threading.py", line 1044, in _bootstrap_inner
    self.run()
    │    └ <function Thread.run at 0x71184fe176a0>
    └ <Thread(asyncio_0, started 124349079893696)>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/threading.py", line 995, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {}
    │    │        │    │        └ <Thread(asyncio_0, started 124349079893696)>
    │    │        │    └ (<weakref at 0x7118463af510; to 'concurrent.futures.thread.ThreadPoolExecutor' at 0x7118463963f0>, <_queue.SimpleQueue object...
    │    │        └ <Thread(asyncio_0, started 124349079893696)>
    │    └ <function _worker at 0x71184f4e04a0>
    └ <Thread(asyncio_0, started 124349079893696)>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/concurrent/futures/thread.py", line 93, in _worker
    work_item.run()
    │         └ <function _WorkItem.run at 0x71184f4e05e0>
    └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
  File "/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             │    │   │    │       │    └ {}
             │    │   │    │       └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
             │    │   │    └ ()
             │    │   └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
             │    └ functools.partial(<bound method SyncToAsync.thread_handler of <asgiref.sync.SyncToAsync object at 0x711846e158b0>>, <_UnixSel...
             └ <concurrent.futures.thread._WorkItem object at 0x711846162350>
> File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 577, in thread_handler
    raise exc_info[1]
          └ (<class 'django.db.utils.DataError'>, DataError('value too long for type character varying(20)\n'), <traceback object at 0x71...
  File "/.venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
                     │            └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
                     └ <bound method BaseHandler._get_response_async of <django.core.handlers.asgi.ASGIHandler object at 0x711848fb96a0>>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 577, in thread_handler
    raise exc_info[1]
          └ (<class 'django.db.utils.DataError'>, DataError('value too long for type character varying(20)\n'), <traceback object at 0x71...
  File "/.venv/lib/python3.13/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
                     └ <asgiref.sync.SyncToAsync object at 0x7118461399a0>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 526, in __call__
    ret = await asyncio.shield(exec_coro)
                │       │      └ <Future finished exception=DataError('value too long for type character varying(20)\n')>
                │       └ <function shield at 0x71184f599620>
                └ <module 'asyncio' from '/root/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/asyncio/__init__.py'>
  File "/.venv/lib/python3.13/site-packages/asgiref/current_thread_executor.py", line 35, in run
    result = self.fn(*self.args, **self.kwargs)
             │        │            └ None
             │        └ None
             └ None
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 581, in thread_handler
    return func(*args, **kwargs)
           │     │       └ {}
           │     └ (functools.partial(<function ModelAdmin.add_view at 0x711847b967a0>, <ASGIRequest: POST '/admin/announcements/announcement/ad...
           └ <function SyncToAsync.__call__.<locals>.func at 0x711846127a60>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 508, in func
    return context.run(run_child)
           │       │   └ <function SyncToAsync.__call__.<locals>.func.<locals>.run_child at 0x711846126ac0>
           │       └ <method 'run' of '_contextvars.Context' objects>
           └ <_contextvars.Context object at 0x711847bbbdc0>
  File "/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 506, in run_child
    return child()
           └ functools.partial(<function ModelAdmin.add_view at 0x711847b967a0>, <ASGIRequest: POST '/admin/announcements/announcement/add...
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 720, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
           │    │          │          │      │       └ {}
           │    │          │          │      └ (<ASGIRequest: POST '/admin/announcements/announcement/add/'>,)
           │    │          │          └ <bound method ModelAdmin.add_view of <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>>
           │    │          └ <function AdminSite.admin_view at 0x71184e4baf20>
           │    └ AdminSite(name='admin')
           └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 192, in _view_wrapper
    result = _process_exception(request, e)
             │                  └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
             └ <function make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception at 0x711846126840>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 190, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               │         │         │       └ {}
               │         │         └ ()
               │         └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
               └ <function AdminSite.admin_view.<locals>.inner at 0x7118461268e0>
  File "/.venv/lib/python3.13/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               │         │         │       └ {}
               │         │         └ ()
               │         └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
               └ <function AdminSite.admin_view.<locals>.inner at 0x711846126980>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/sites.py", line 246, in inner
    return view(request, *args, **kwargs)
           │    │         │       └ {}
           │    │         └ ()
           │    └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
           └ <bound method ModelAdmin.add_view of <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1985, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
           │    │               │              │         └ None
           │    │               │              └ ''
           │    │               └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
           │    └ <function ModelAdmin.changeform_view at 0x71184e4a8540>
           └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
           │             │       └ {}
           │             └ (<ASGIRequest: POST '/admin/announcements/announcement/add/'>, None, '', None)
           └ <function ModelAdmin.changeform_view at 0x711846126480>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 192, in _view_wrapper
    result = _process_exception(request, e)
             │                  └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
             └ <function make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception at 0x7118461265c0>
  File "/.venv/lib/python3.13/site-packages/django/utils/decorators.py", line 190, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               │         │         │       └ {}
               │         │         └ (None, '', None)
               │         └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
               └ functools.partial(<bound method ModelAdmin.changeform_view of <AnnouncementExpansion: model=Announcement site=AdminSite(name=...
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1844, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
           │    │                │        │          │         └ None
           │    │                │        │          └ ''
           │    │                │        └ None
           │    │                └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
           │    └ <function ModelAdmin._changeform_view at 0x71184e4a8860>
           └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1895, in _changeform_view
    self.save_model(request, new_object, form, not add)
    │    │          │        │           │         └ True
    │    │          │        │           └ <AnnouncementForm bound=True, valid=True, fields=(title;level;placement;text;is_active;priority)>
    │    │          │        └ <Announcement: MAIN>
    │    │          └ <ASGIRequest: POST '/admin/announcements/announcement/add/'>
    │    └ <function ModelAdmin.save_model at 0x71184e4a7920>
    └ <AnnouncementExpansion: model=Announcement site=AdminSite(name='admin')>
  File "/.venv/lib/python3.13/site-packages/django/contrib/admin/options.py", line 1315, in save_model
    obj.save()
    │   └ <function Model.save at 0x71184eccf9c0>
    └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
    │    └ <function Model.save_base at 0x71184eccfba0>
    └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 1008, in save_base
    updated = self._save_table(
              │    └ <function Model._save_table at 0x71184eccfce0>
              └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 1169, in _save_table
    results = self._do_insert(
              │    └ <function Model._do_insert at 0x71184eccfe20>
              └ <Announcement: MAIN>
  File "/.venv/lib/python3.13/site-packages/django/db/models/base.py", line 1210, in _do_insert
    return manager._insert(
           │       └ <function QuerySet._insert at 0x71184ee58360>
           └ <django.db.models.manager.Manager object at 0x711846398c50>
  File "/.venv/lib/python3.13/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
                   │    │               │      │       └ {'fields': [<django.db.models.fields.CharField: title>, <django.db.models.fields.TextField: text>, <django.db.models.fields.C...
                   │    │               │      └ ([<Announcement: MAIN>],)
                   │    │               └ '_insert'
                   │    └ <function BaseManager.get_queryset at 0x71184ee58040>
                   └ <django.db.models.manager.Manager object at 0x711846398c50>
  File "/.venv/lib/python3.13/site-packages/django/db/models/query.py", line 1873, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           │     │                  │                  └ [<django.db.models.fields.BigAutoField: id>]
           │     │                  └ 'default'
           │     └ <function Query.get_compiler at 0x71184edd3f60>
           └ <django.db.models.sql.subqueries.InsertQuery object at 0x7118463b79b0>
  File "/.venv/lib/python3.13/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql
    cursor.execute(sql, params)
    │      │       │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
    │      │       └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
    │      └ <function CursorDebugWrapper.execute at 0x71184ef694e0>
    └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 122, in execute
    return super().execute(sql, params)
                           │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
                           └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           │    └ <function CursorWrapper._execute_with_wrappers at 0x71184ef69300>
           └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           │        │    │       │     └ {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.postgresql.base.CursorDeb...
           │        │    │       └ False
           │        │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
           │        └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
           └ <bound method CursorWrapper._execute of <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>>
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
         │    │  └ <django.db.utils.DatabaseErrorWrapper object at 0x7118463acf50>
         │    └ <DatabaseWrapper vendor='postgresql' alias='default'>
         └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>
  File "/.venv/lib/python3.13/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
          │            │              │               └ StringDataRightTruncation('value too long for type character varying(20)\n')
          │            │              └ <traceback object at 0x711845066a00>
          │            └ <method 'with_traceback' of 'BaseException' objects>
          └ DataError('value too long for type character varying(20)\n')
  File "/.venv/lib/python3.13/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           │    │      │       │    └ ('MAIN', 'QSODK', 'critical', 'home_page_and_platform', True, 0, datetime.datetime(2026, 10, 20, 10, 28, 23, 377568, tzinfo=d...
           │    │      │       └ 'INSERT INTO "announcements_announcement" ("title", "text", "level", "placement", "is_active", "priority", "created_when") VA...
           │    │      └ <method 'execute' of 'psycopg2.extensions.cursor' objects>
           │    └ <cursor object at 0x711848e049a0; closed: -1>
           └ <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x711844df08f0>

django.db.utils.DataError: value too long for type character varying(20)

The other kind of announcements still works fine.

@Didayolo Didayolo changed the title Announcements - Platform-wide announcements aded Announcements - Platform-wide announcements added Oct 20, 2026
- Announcements can now be placed on the home page only or on all pages
- All pages announcements show as a thin colored banner above the header on every page
- Home page shows only its own announcements
- Placement added to the announcements admin
- Tests for home page and platform announcements
- New placement choice to show an announcement on both the home page and the banner on every page
- Placement migration regenerated so the feature keeps a single migration
- Tests for the new placement on the home page and in the banner
@Didayolo
Didayolo force-pushed the site_wise_announcements branch from 2dc973d to 51eaf2b Compare October 20, 2026 13:15
@Didayolo

Copy link
Copy Markdown
Member

Maybe in a next PR, but we should be able to dismiss the "platform wide" annoucements

@Didayolo

Didayolo commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

@ObadaS I tested and could not reproduce the bug you are showing here. On my side it's all good.

EDIT: Ihsan made an update 5 minutes ago so maybe I got lucky!

@ObadaS

ObadaS commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

@ObadaS I tested and could not reproduce the bug you are showing here. On my side it's all good.

Maybe my local instance was broken. I guess we can merge this then test on the preprod instance to make sure

@Didayolo
Didayolo merged commit d454b9f into develop Oct 20, 2026
4 checks passed
@Didayolo
Didayolo deleted the site_wise_announcements branch October 20, 2026 13:37
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.

Site-wide announcements

3 participants