Skip to content

Commit

Permalink
Merge pull request #1150 from ubyssey/last-working-authors-bio
Browse files Browse the repository at this point in the history
Redid merges
  • Loading branch information
brittkhat authored Jul 14, 2023
2 parents 025f389 + 0160f7f commit 695d33f
Show file tree
Hide file tree
Showing 26 changed files with 390 additions and 177 deletions.
24 changes: 24 additions & 0 deletions article/migrations/0019_alter_articlepage_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.11 on 2023-07-13 21:44

from django.db import migrations
import images.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.embeds.blocks
import wagtail.images.blocks
import wagtail.snippets.blocks


class Migration(migrations.Migration):

dependencies = [
('article', '0018_articlepage_noindex'),
]

operations = [
migrations.AlterField(
model_name='articlepage',
name='content',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(help_text='Write your article contents here. See documentation: https://docs.wagtail.io/en/latest/editor_manual/new_pages/creating_body_content.html#rich-text-fields', label='Rich Text Block')), ('plaintext', wagtail.core.blocks.TextBlock(help_text='Warning: Rich Text Blocks preferred! Plain text primarily exists for importing old Dispatch text.', label='Plain Text Block')), ('dropcap', wagtail.core.blocks.TextBlock(help_text='DO NOT USE - Legacy block. Create a block where special dropcap styling with be applied to the first letter and the first letter only.\n\nThe contents of this block will be enclosed in a <p class="drop-cap">...</p> element, allowing its targetting for styling.\n\nNo RichText allowed.', label='Dropcap Block', template='article/stream_blocks/dropcap.html')), ('video', wagtail.core.blocks.StructBlock([('video_embed', wagtail.embeds.blocks.EmbedBlock(blank=False, null=False)), ('title', wagtail.core.blocks.CharBlock(max_length=255, required=False)), ('caption', wagtail.core.blocks.CharBlock(max_length=255, required=False)), ('credit', wagtail.core.blocks.CharBlock(max_length=255, required=False))], help_text='Use this to credit or caption videos that will only be associated with this current article, rather than entered into our video library. You can also embed videos in a Rich Text Block.', label='Credited/Captioned One-Off Video')), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(required=True)), ('style', wagtail.core.blocks.ChoiceBlock(choices=[('default', 'Default'), ('left', 'Left'), ('right', 'Right')])), ('width', wagtail.core.blocks.ChoiceBlock(choices=[('full', 'Full'), ('small', 'Small'), ('medium', 'Medium'), ('large', 'Large')])), ('caption', wagtail.core.blocks.CharBlock(max_length=255, required=False)), ('credit', wagtail.core.blocks.CharBlock(max_length=255, required=False))])), ('raw_html', wagtail.core.blocks.RawHTMLBlock(help_text="WARNING: DO NOT use this unless you really know what you're doing!", label='Raw HTML Block')), ('quote', wagtail.core.blocks.StructBlock([('content', wagtail.core.blocks.CharBlock(required=False)), ('source', wagtail.core.blocks.CharBlock(required=False))], icon='openquote', label='Pull Quote', template='article/stream_blocks/quote.html')), ('gallery', wagtail.snippets.blocks.SnippetChooserBlock(target_model=images.models.GallerySnippet, template='article/stream_blocks/gallery.html'))], blank=True, null=True),
),
]
16 changes: 3 additions & 13 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,7 @@ class ArticleAuthorsOrderable(Orderable):
('illustrator','Illustrator'),
('photographer','Photographer'),
('videographer','Videographer'),
("coordinating editor", "Coordinating Editor"),
("news editor", "News Editor"),
("news producer", "News Producer"),
("features editor", "Features Editor"),
("humour editor", "Humour Editor"),
("culture editor", "Culture Editor"),
("opinion editor", "Opinion Editor"),
("video editor", "Video Editor"),
("photo editor", "Photo Editor"),
("visuals editor", "Visuals Editor"),
("sports editor", "Sports Editor"),
("science editor", "Science Editor"),
('org_role', 'Show organization role'),
],
),
),
Expand Down Expand Up @@ -492,6 +481,7 @@ class ArticlePage(SectionablePage, UbysseyMenuMixin):
],
label = "Pull Quote",
template = 'article/stream_blocks/quote.html',
icon = "openquote",
)),
('gallery', SnippetChooserBlock(
target_model = GallerySnippet,
Expand Down Expand Up @@ -991,7 +981,7 @@ def get_authors_with_urls(self) -> str:
authors_with_urls = property(fget=get_authors_with_urls)

def get_authors_in_order(self):
AUTHOR_TYPES = ["author", "photographer", "illustrator", "videographer", "coordinating editor", "news editor", "news producer", "features editor", "humour editor", "culture editor", "opinion editor", "video editor", "photo editor", "visuals editor", "sports editor", "science editor"]
AUTHOR_TYPES = ["org_role", "author", "photographer", "illustrator", "videographer"]
authors = self.article_authors.all()

authors_list = []
Expand Down
17 changes: 10 additions & 7 deletions article/templates/article/objects/author_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
<div class="author_image_container">
{% image author.author.image width-200 class="author_image" %}
</div>
{% elif self.article_authors.all|all_no_images == True %}
<div class="author_image_container"></div>
{% else %}
<div class="author_image_container no_image"></div>
{% endif %}


<div class="authors_info_inner">
<!-- if forloop.first and no image then 0 padding for the authors_info left, author_info and author title-->
<div class="authors_info_inner {% if author.author.display_image == False %} no_image {% endif %}">
<div class="author_info">
<div class="author_title"><a href="{{ author.author.author.full_url }}">{{ author.author.full_name|safe }}</a></div> <div class="author_role">{{author.author_role}}</div>
<div class="author_title"><a href="{{ author.author.full_url }}">{{ author.author.full_name|safe }}</a></div>
<div class="author_role">
{% if author.author_role == "org_role" %}
{{author.author.ubyssey_role}}
{% else %}
{{author.author_role}}
{% endif %}
</div>
</div>

{% if author.author.short_bio_description != "" %}
Expand Down
136 changes: 134 additions & 2 deletions dashboard/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,141 @@
from django.utils.html import format_html
from django.templatetags.static import static


from wagtail.core import hooks

import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler

@hooks.register('insert_global_admin_css')
def global_admin_css():
return format_html('<link rel="stylesheet" href="{}">', static('css/custom.css'))
return format_html('<link rel="stylesheet" href="{}">', static('css/custom.css'))

# 1. Use the register_rich_text_features hook.
@hooks.register('register_rich_text_features')
def register_strikethrough_feature(features):
"""
Registering the `mark` feature, which uses the `MARK` Draft.js inline style type,
and is stored as HTML with a `<mark>` tag.
"""
feature_name = 'strikethrough'
type_ = 'STRIKETHROUGH'
tag = 'strikethrough'

# 2. Configure how Draftail handles the feature in its toolbar.
control = {
'type': type_,
'label': 's',
'description': 'Strikethrough',
# This isn’t even required – Draftail has predefined styles for MARK.
# 'style': {'textDecoration': 'line-through'},
}

# 3. Call register_editor_plugin to register the configuration for Draftail.
features.register_editor_plugin(
'draftail', feature_name, draftail_features.InlineStyleFeature(control)
)

# 4.configure the content transform from the DB to the editor and back.
db_conversion = {
'from_database_format': {tag: InlineStyleElementHandler(type_)},
'to_database_format': {'style_map': {type_: tag}},
}

# 5. Call register_converter_rule to register the content transformation conversion.
features.register_converter_rule('contentstate', feature_name, db_conversion)

# 6. (optional) Add the feature to the default features list to make it available
# on rich text fields that do not specify an explicit 'features' list
features.default_features.append('strikethrough')

@hooks.register("register_rich_text_features")
def register_centertext_feature(features):
"""Creates centered text in our richtext editor and page."""

# Step 1
feature_name = "center"
type_ = "CENTERTEXT"
tag = "div"

# Step 2
control = {
"type": type_,
"label": "Center",
"description": "Center Text",
"style": {
"display": "block",
"text-align": "center",
},
}

# Step 3
features.register_editor_plugin(
"draftail", feature_name, draftail_features.InlineStyleFeature(control)
)

# Step 4
db_conversion = {
"from_database_format": {tag: InlineStyleElementHandler(type_)},
"to_database_format": {
"style_map": {
type_: {
"element": tag,
"props": {
"class": "d-block text-center"
}
}
}
}
}

# Step 5
features.register_converter_rule("contentstate", feature_name, db_conversion)

# Step 6, This is optional.
features.default_features.append(feature_name)

@hooks.register("register_rich_text_features")
def register_righttext_feature(features):
"""Creates centered text in our richtext editor and page."""

# Step 1
feature_name = "right"
type_ = "RIGHTTEXT"
tag = "div"

# Step 2
control = {
"type": type_,
"label": "Right",
"description": "Right Text",
"style": {
"display": "block",
"text-align": "right",
},
}

# Step 3
features.register_editor_plugin(
"draftail", feature_name, draftail_features.InlineStyleFeature(control)
)

# Step 4
db_conversion = {
"from_database_format": {tag: InlineStyleElementHandler(type_)},
"to_database_format": {
"style_map": {
type_: {
"element": tag,
"props": {
"class": "d-block text-right"
}
}
}
}
}

# Step 5
features.register_converter_rule("contentstate", feature_name, db_conversion)

# Step 6, This is optional.
features.default_features.append(feature_name)
1 change: 1 addition & 0 deletions images/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ class ImageBlock(blocks.StructBlock):

class Meta:
template = 'images/stream_blocks/image_block.html'
icon = 'image'
5 changes: 4 additions & 1 deletion navigation/templates/navigation/headers/mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<header class="mobile dark-mode">
<script src="{% static 'ubyssey/js/darkmode.js' %}" type="text/javascript"></script>
<a class="menu left" href="#"><i class="fa fa-bars"></i></a>
<a class="logo" href="{% url 'wagtail_serve' '' %}"><img class="ubyssey_small_logo" src="{% static 'ubyssey/images/ubyssey-logo-small.svg' %}" alt=""></a>
<a class="logo" href="{% url 'wagtail_serve' '' %}">
<img class="ubyssey_small_logo light-logo" src="{% static 'ubyssey/images/ubyssey-logo-small.svg' %}" alt=""/>
<img class="ubyssey_small_logo dark-logo" src="{% static 'ubyssey/images/ubyssey-logo 1.svg' %}" alt=""/>
</a>
{% comment %} <a class="search right" href="{% url 'search' %}"><i class="fa fa-search"></i></a> {% endcomment %}
</header>
<div id="header-mobile-spacer{% if class %}--{{ class }}{% endif %}"></div>
Expand Down
5 changes: 4 additions & 1 deletion navigation/templates/navigation/headers/topbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

<header class="topbar header-site dark-mode">
<div class="u-container u-container-topbar">
<a class="home-link" href="{% url 'wagtail_serve' '' %}"><img class="logo ubyssey_small_logo" src="{% static 'ubyssey/images/ubyssey-logo-small.svg' %}" alt=""/></a>
<a class="home-link" href="{% url 'wagtail_serve' '' %}">
<img class="logo ubyssey_small_logo light-logo" src="{% static 'ubyssey/images/ubyssey-logo-small.svg' %}" alt=""/>
<img class="logo ubyssey_small_logo dark-logo" src="{% static 'ubyssey/images/ubyssey-logo 1.svg' %}" alt=""/>
</a>
<nav>
{% main_menu show_multiple_levels=False apply_active_classes=True %}
</nav>
Expand Down
2 changes: 1 addition & 1 deletion newsletter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.views.generic import View

def mailchimp_landing_redirect(self):
response = redirect('https://mailchi.mp/8c879257bf61/subscribe-to-our-newsletter')
response = redirect('https://embeds.beehiiv.com/8cc31358-f28d-486d-b3ad-99cdf843ce88')
return response

# class WebhookResponseHandlerView(View):
Expand Down
2 changes: 1 addition & 1 deletion requirements-prd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ua-parser==0.10.0
user-agents==2.2.0
django-user_agents==0.4.0
gunicorn==20.0.4
Pillow==9.0.1
Pillow==9.3.0
google-cloud-datastore==1.15.0
google-cloud-storage==1.31.0
google-cloud-secret-manager==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ua-parser==0.10.0
user-agents==2.2.0
django-user_agents==0.4.0
gunicorn==20.0.4
Pillow==9.0.1
Pillow==9.3.0
google-cloud-datastore==1.15.0
google-cloud-storage==1.31.0
google-cloud-secret-manager==2.11.0
Expand Down
3 changes: 2 additions & 1 deletion section/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def get_context(self, request, *args, **kwargs):

def get_section_articles(self, order='-explicit_published_at') -> QuerySet:
# return ArticlePage.objects.from_section(section_root=self)
section_articles = ArticlePage.objects.live().public().filter(current_section=self.slug).order_by(order)
# section_articles = ArticlePage.objects.live().public().filter(current_section=self.slug).order_by(order)
section_articles = ArticlePage.objects.live().public().descendant_of(self).order_by(order)
return section_articles

def get_featured_articles(self, queryset=None, number_featured=4) -> QuerySet:
Expand Down
Loading

0 comments on commit 695d33f

Please sign in to comment.