Skip to content
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

feat: control displayed sponsors #1199

Merged
merged 5 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions src/locale/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PyCon TW\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-15 17:45+0800\n"
"POT-Creation-Date: 2024-06-21 07:48+0800\n"
"PO-Revision-Date: 2022-07-11 02:23+0800\n"
"Last-Translator: Tom Chen <[email protected]>\n"
"Language-Team: English (United States) (http://www.transifex.com/pycon-"
Expand Down Expand Up @@ -506,7 +506,7 @@ msgstr "keynote events"
msgid "Keynote: {speaker}"
msgstr "Keynote: {speaker}"

#: events/models.py:318 sponsors/models.py:97 sponsors/models.py:113
#: events/models.py:318 sponsors/models.py:103 sponsors/models.py:119
msgid "sponsor"
msgstr "sponsor"

Expand Down Expand Up @@ -1418,107 +1418,111 @@ msgstr "Stage {stage} dump for {proposal}"
msgid "name"
msgstr "name"

#: sponsors/models.py:27
#: sponsors/models.py:28
msgid "is shown"
msgstr "is_shown"
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved

#: sponsors/models.py:33
msgid "website URL"
msgstr "website URL"

#: sponsors/models.py:31
#: sponsors/models.py:37
msgid "introduction"
msgstr "introduction"

#: sponsors/models.py:34
#: sponsors/models.py:40
msgid "subtitle"
msgstr "subtitle"

#: sponsors/models.py:39
#: sponsors/models.py:45
msgid "logo (SVG)"
msgstr "logo (SVG)"

#: sponsors/models.py:42
#: sponsors/models.py:48
msgid ""
"Vector format of the logo, in SVG. This takes precedence to the raster "
"format, if available."
msgstr ""
"Vector format of the logo, in SVG. This takes precedence to the raster "
"format, if available."

#: sponsors/models.py:47
#: sponsors/models.py:53
msgid "logo (image)"
msgstr "logo (image)"

#: sponsors/models.py:51
#: sponsors/models.py:57
msgid ""
"Raster format of the logo, e.g. PNG, JPEG. This is used as fallback when the "
"SVG file is not available."
msgstr ""
"Raster format of the logo, e.g. PNG, JPEG. This is used as fallback when the "
"SVG file is not available."

#: sponsors/models.py:56
#: sponsors/models.py:62
msgid "order"
msgstr "order"

#: sponsors/models.py:76
#: sponsors/models.py:82
msgid "platinum"
msgstr "platinum"

#: sponsors/models.py:77
#: sponsors/models.py:83
msgid "gold"
msgstr "gold"

#: sponsors/models.py:78
#: sponsors/models.py:84
msgid "silver"
msgstr "silver"

#: sponsors/models.py:79
#: sponsors/models.py:85
msgid "bronze"
msgstr "bronze"

#: sponsors/models.py:80
#: sponsors/models.py:86
msgid "special"
msgstr "special"

#: sponsors/models.py:81
#: sponsors/models.py:87
msgid "special-thanks"
msgstr "special-thanks"

#: sponsors/models.py:82
#: sponsors/models.py:88
msgid "organizer"
msgstr "organizer"

#: sponsors/models.py:83
#: sponsors/models.py:89
msgid "co-organizer"
msgstr "co-organizer"

#: sponsors/models.py:92
#: sponsors/models.py:98
msgid "level"
msgstr "level"

#: sponsors/models.py:98
#: sponsors/models.py:104
msgid "sponsors"
msgstr "sponsors"

#: sponsors/models.py:118
#: sponsors/models.py:124
msgid "open role name"
msgstr "open role name"

#: sponsors/models.py:123
#: sponsors/models.py:129
msgid "open role description"
msgstr "open role description"

#: sponsors/models.py:127
#: sponsors/models.py:133
msgid "open role requirements"
msgstr "open role requirements"

#: sponsors/models.py:132
#: sponsors/models.py:138
msgid "open role URL"
msgstr "open role URL"

#: sponsors/models.py:137
#: sponsors/models.py:143
msgid "open role"
msgstr "open role"

#: sponsors/models.py:138
#: sponsors/models.py:144
msgid "open roles"
msgstr "open roles"

Expand Down
56 changes: 30 additions & 26 deletions src/locale/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PyCon TW\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-15 17:45+0800\n"
"POT-Creation-Date: 2024-06-21 07:48+0800\n"
"PO-Revision-Date: 2022-07-11 02:25+0800\n"
"Last-Translator: Tom Chen <[email protected]>\n"
"Language-Team: Chinese Traditional (http://www.transifex.com/pycon-taiwan/"
Expand Down Expand Up @@ -513,7 +513,7 @@ msgstr "基調演講"
msgid "Keynote: {speaker}"
msgstr "基調演講:{speaker}"

#: events/models.py:318 sponsors/models.py:97 sponsors/models.py:113
#: events/models.py:318 sponsors/models.py:103 sponsors/models.py:119
msgid "sponsor"
msgstr "贊助"

Expand Down Expand Up @@ -1375,104 +1375,108 @@ msgstr "第 {stage} 階段封存《{proposal}》"
msgid "name"
msgstr "名稱"

#: sponsors/models.py:27
#: sponsors/models.py:28
msgid "is shown"
msgstr "顯示於官網"

#: sponsors/models.py:33
msgid "website URL"
msgstr "網站 URL"

#: sponsors/models.py:31
#: sponsors/models.py:37
msgid "introduction"
msgstr "簡介"

#: sponsors/models.py:34
#: sponsors/models.py:40
msgid "subtitle"
msgstr "副標題"

#: sponsors/models.py:39
#: sponsors/models.py:45
msgid "logo (SVG)"
msgstr "logo (SVG)"

#: sponsors/models.py:42
#: sponsors/models.py:48
msgid ""
"Vector format of the logo, in SVG. This takes precedence to the raster "
"format, if available."
msgstr "即使有點陣式圖形格式的圖標,還是會優先採用向量式SVG格式的圖標。"

#: sponsors/models.py:47
#: sponsors/models.py:53
msgid "logo (image)"
msgstr "logo (圖片)"

#: sponsors/models.py:51
#: sponsors/models.py:57
msgid ""
"Raster format of the logo, e.g. PNG, JPEG. This is used as fallback when the "
"SVG file is not available."
msgstr ""
"當SVG格式的檔案不存在時,會回過頭來使用點陣式格式的圖標,例如PNG、JPEG。"

#: sponsors/models.py:56
#: sponsors/models.py:62
msgid "order"
msgstr "排序"

#: sponsors/models.py:76
#: sponsors/models.py:82
msgid "platinum"
msgstr "白金級"

#: sponsors/models.py:77
#: sponsors/models.py:83
msgid "gold"
msgstr "金級"

#: sponsors/models.py:78
#: sponsors/models.py:84
msgid "silver"
msgstr "銀級"

#: sponsors/models.py:79
#: sponsors/models.py:85
msgid "bronze"
msgstr "銅級"

#: sponsors/models.py:80
#: sponsors/models.py:86
msgid "special"
msgstr "特別贊助"

#: sponsors/models.py:81
#: sponsors/models.py:87
msgid "special-thanks"
msgstr "特別感謝"

#: sponsors/models.py:82
#: sponsors/models.py:88
msgid "organizer"
msgstr "主辦單位"

#: sponsors/models.py:83
#: sponsors/models.py:89
msgid "co-organizer"
msgstr "協辦單位"

#: sponsors/models.py:92
#: sponsors/models.py:98
msgid "level"
msgstr "等級"

#: sponsors/models.py:98
#: sponsors/models.py:104
msgid "sponsors"
msgstr "贊助"

#: sponsors/models.py:118
#: sponsors/models.py:124
msgid "open role name"
msgstr "職缺名稱"

#: sponsors/models.py:123
#: sponsors/models.py:129
msgid "open role description"
msgstr "職缺說明"

#: sponsors/models.py:127
#: sponsors/models.py:133
msgid "open role requirements"
msgstr "職缺需求"

#: sponsors/models.py:132
#: sponsors/models.py:138
msgid "open role URL"
msgstr "職缺 URL"

#: sponsors/models.py:137
#: sponsors/models.py:143
msgid "open role"
msgstr "職缺"

#: sponsors/models.py:138
#: sponsors/models.py:144
msgid "open roles"
msgstr "職缺"

Expand Down
2 changes: 1 addition & 1 deletion src/sponsors/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@admin.register(Sponsor)
class SponsorAdmin(TranslationAdmin):
fields = [
'name', 'level', 'website_url', 'intro', 'subtitle',
'name', 'level', 'is_shown', 'website_url', 'intro', 'subtitle',
'logo_svg', 'logo_image', 'order'
]
list_display = ['name', 'level', 'order']
Expand Down
3 changes: 3 additions & 0 deletions src/sponsors/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def get(self, request):
if sponsor.level_en_name not in level_dict:
level_dict[sponsor.level_en_name] = []

if sponsor.is_shown is False:
continue

level_dict[sponsor.level_en_name].append({
"name_en_us": sponsor.name_en_us,
"name_zh_hant": sponsor.name_zh_hant,
Expand Down
18 changes: 18 additions & 0 deletions src/sponsors/migrations/0033_sponsor_is_shown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2024-06-02 09:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sponsors', '0032_fix_verbose_typo'),
]

operations = [
migrations.AddField(
model_name='sponsor',
name='is_shown',
field=models.BooleanField(default=False, verbose_name='is shown'),
),
]
6 changes: 6 additions & 0 deletions src/sponsors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class Sponsor(ConferenceRelated):
verbose_name=_('name'),
max_length=100,
)

is_shown = models.BooleanField(
verbose_name=_('is shown'),
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved
default=False,
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved
)

website_url = models.URLField(
verbose_name=_('website URL'),
max_length=255, blank=True,
Expand Down
13 changes: 7 additions & 6 deletions src/sponsors/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
@pytest.fixture(autouse=True, scope='function')
def test_data():
# sponsors
# platinum
sponsor_1 = Sponsor.objects.create(name='1', level=1)
# gold
sponsor_2 = Sponsor.objects.create(name='2', level=2, order=2)
sponsor_3 = Sponsor.objects.create(name='3', level=2, order=None) # noqa
sponsor_4 = Sponsor.objects.create(name='4', level=2, order=1) # noqa
# # platinum
sponsor_1 = Sponsor.objects.create(name='1', level=1, is_shown=True)
# # gold
sponsor_2 = Sponsor.objects.create(name='2', level=2, order=2, is_shown=True)
sponsor_3 = Sponsor.objects.create(name='3', level=2, order=None, is_shown=True) # noqa
sponsor_4 = Sponsor.objects.create(name='4', level=2, order=1, is_shown=True) # noqa
sponsor_5 = Sponsor.objects.create(name='5', level=2, order=3, is_shown=False) # noqa

# roles
OpenRole.objects.create(sponsor=sponsor_1, name='11', description='...')
Expand Down
Loading