-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish topic channels based on resource count (#1349)
* add channel published field * perform deletion during resource_delete_actions * make channel_url null if not published * fix bad rebase :( * add a data migration * return 404 for unpublished channels * add another test * fix typo (haha pun) * rename migration function * bump migration number * bump migration
- Loading branch information
1 parent
7aaaa40
commit 5ef8945
Showing
22 changed files
with
324 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.2.14 on 2024-08-06 14:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("channels", "0014_dept_detail_related_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="channel", | ||
name="published", | ||
field=models.BooleanField(db_index=True, default=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from urllib.parse import urlparse | ||
|
||
import pytest | ||
|
||
from channels.constants import ChannelType | ||
from channels.factories import ( | ||
ChannelDepartmentDetailFactory, | ||
ChannelTopicDetailFactory, | ||
ChannelUnitDetailFactory, | ||
) | ||
|
||
pytestmark = [pytest.mark.django_db] | ||
|
||
|
||
@pytest.mark.parametrize("published", [True, False]) | ||
@pytest.mark.parametrize( | ||
( | ||
"channel_type", | ||
"detail_factory", | ||
), | ||
[ | ||
(ChannelType.department, ChannelDepartmentDetailFactory), | ||
(ChannelType.topic, ChannelTopicDetailFactory), | ||
(ChannelType.unit, ChannelUnitDetailFactory), | ||
], | ||
) | ||
def test_channel_url_for_departments(published, channel_type, detail_factory): | ||
"""Test that the channel URL is correct for department channels""" | ||
channel = detail_factory.create( | ||
channel__published=published, | ||
).channel | ||
|
||
if published: | ||
assert ( | ||
urlparse(channel.channel_url).path | ||
== f"/c/{channel_type.name}/{channel.name}/" | ||
) | ||
else: | ||
assert channel.channel_url is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.