Skip to content

Commit

Permalink
[CPCN-486] Final ajustments
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzSF committed Dec 5, 2023
2 parents 8cfa4f5 + 6c06b03 commit 8e63ecb
Show file tree
Hide file tree
Showing 30 changed files with 16,457 additions and 108 deletions.
4 changes: 2 additions & 2 deletions assets/company-reports/components/SubscriberActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ class SubscriberActivity extends React.Component<any, any> {
...filterNodes,
(<CalendarButton
key='subscriver_activity_from'
labelClass='ms-3 mt-1'
labelClass='ms-3 d-flex align-items-center'
label={gettext('FROM:')}
selectDate={this.onFromDateChange}
activeDate={get(reportParams, 'date_from') || moment()} />),
(<CalendarButton
key='subscriver_activity_to'
labelClass='mt-1'
labelClass='d-flex align-items-center'
label={gettext('TO:')}
selectDate={this.onEndDateChange}
activeDate={get(reportParams, 'date_to') || moment()} />)
Expand Down
44 changes: 24 additions & 20 deletions assets/components/CalendarButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,35 @@ class CalendarButton extends React.Component<any, any> {

render() {
const isStartDateToday = moment.isMoment(this.state.startDate) && !this.state.startDate.isSame(moment(), 'day');
const datePicker = (<DatePicker
customInput={<CalendarButtonWrapper active={isStartDateToday}/>}
dateFormat="yyyy-MM-dd"
todayButton={gettext('Today')}
selected={this.state.startDate}
onChange={this.handleChange}
highlightDates={[moment().toDate()]}
locale={window.locale || 'en'}
popperModifiers={[
{
name: 'offset',
options: {
offset: [5, 10],
const datePicker = (
<DatePicker
customInput={<CalendarButtonWrapper active={isStartDateToday}/>}
dateFormat="yyyy-MM-dd"
todayButton={gettext('Today')}
selected={this.state.startDate}
onChange={this.handleChange}
highlightDates={[moment().toDate()]}
locale={window.locale || 'en'}
popperModifiers={[
{
name: 'offset',
options: {
offset: [5, 10],
},
},
},
]}
/>);
]}
/>
);

if (!this.props.label) {
return datePicker;
} else {
return (<div className={this.props.labelClass}>
<label className='pe-1'>{this.props.label}</label>
{datePicker}
</div>);
return (
<div className={this.props.labelClass}>
<label className='pe-1 label--no-spacing'>{this.props.label}</label>
{datePicker}
</div>
);

}
}
Expand Down
1 change: 1 addition & 0 deletions assets/layout/components/BaseApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import FiltersTab from 'wire/components/filters/FiltersTab';
import NavigationTab from 'wire/components/filters/NavigationTab';
import {AdvancedSearchPanel} from 'search/components/AdvancedSearchPanel';
import {SearchTipsPanel} from 'search/components/SearchTipsPanel';
import '@superdesk/common/dist/src/index.css';

export default class BaseApp extends React.Component<any, any> {
static propTypes: any;
Expand Down
2 changes: 1 addition & 1 deletion assets/styles/agenda.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
flex-shrink: 0;
display: grid;
grid-template-rows: auto auto 1fr auto;
max-height: clamp(360px, 65svh, 65svh);
max-height: clamp(360px, 50svh, 50svh);
@include phone {
.search-result__tags-list {
border-bottom: 2px solid var(--main-header-color-bg);
Expand Down
6 changes: 5 additions & 1 deletion assets/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ $nav-sidebar-border: #323847;
label {
color: var(--color-text--muted);
font-size: 14px;
}
label:not(.label--no-spacing) {
margin-block-end: 0.3rem;
}
.label__news-only {
Expand Down Expand Up @@ -2005,7 +2007,7 @@ article.list {
}
}
.wire-column__nav-heading {
font-family: var(--filterpane-section-heading-font-family);
font-family: var(--filterpane-section-heading-font-family);
font-size: var(--filterpane-section-heading-font-size);
font-weight: var(--filterpane-section-heading-font-weight);
text-transform: var(--filterpane-section-heading-text-transform);
Expand Down Expand Up @@ -2195,6 +2197,8 @@ article.list {
}

.wire-column__preview__content {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow: auto;
padding: var(--space--1-5) var(--space--3);
Expand Down
25 changes: 19 additions & 6 deletions assets/wire/components/ItemDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import {isEmpty} from 'lodash';
import PreviewMeta from './PreviewMeta';
import PreviewTags from './PreviewTags';
import AgendaLinks from './AgendaLinks';
Expand All @@ -15,6 +14,9 @@ import {
DISPLAY_ABSTRACT,
isPreformatted,
isCustomRendition,
getPictureList,
getThumbnailRendition,
notNullOrUndefined,
} from 'wire/utils';
import types from 'wire/types';
import Content from 'ui/components/Content';
Expand All @@ -35,6 +37,7 @@ import ArticleEmbargoed from 'ui/components/ArticleEmbargoed';
import PreviewEdnote from './PreviewEdnote';
import WireActionButtons from './WireActionButtons';
import {Authors} from './fields/Authors';
import {Carousel} from '@superdesk/common';

function ItemDetails({
item,
Expand All @@ -51,6 +54,10 @@ function ItemDetails({
const featureMedia = getFeatureMedia(item);
const media = getOtherMedia(item);
const itemType = isPreformatted(item) ? 'preformatted' : 'text';
const carouselItems = getPictureList(item)
.map((image) => getThumbnailRendition(image))
.filter(notNullOrUndefined)
.map((image) => ({src: image.href}));

return (
<Content type="item-detail">
Expand All @@ -69,11 +76,17 @@ function ItemDetails({
<ArticleContent>
{featureMedia == null ? null : (
featureMedia.type === 'picture' ? (
<ArticlePicture
picture={featureMedia}
isKilled={isKilled(item)}
isCustomRendition={isCustomRendition(featureMedia)}
/>
carouselItems.length > 1 ? (
<Carousel
images={carouselItems}
/>
) : (
<ArticlePicture
picture={featureMedia}
isKilled={isKilled(item)}
isCustomRendition={isCustomRendition(featureMedia)}
/>
)
) : (
<ArticleMedia
media={featureMedia}
Expand Down
4 changes: 1 addition & 3 deletions assets/wire/components/WirePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import AgendaLinks from './AgendaLinks';
import PreviewEdnote from './PreviewEdnote';
import WireActionButtons from './WireActionButtons';
import {Authors} from './fields/Authors';
import {downloadMedia} from '../actions';


class WirePreview extends React.PureComponent<any, any> {
static propTypes: any;
Expand All @@ -53,8 +51,8 @@ class WirePreview extends React.PureComponent<any, any> {
const {item, user, actions, followStory, topics, previewConfig, downloadMedia, listConfig, filterGroupLabels} = this.props;
const featureMedia = getFeatureMedia(item);
const media = getOtherMedia(item);

const previousVersions = 'preview_versions';

return (
<Preview onCloseClick={this.props.closePreview} published={item.versioncreated}>
<div className='wire-column__preview__top-bar'>
Expand Down
14 changes: 9 additions & 5 deletions assets/wire/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ export function getOtherMedia(item: IArticle): Array<IArticle> | null {
return null;
}

return Object.entries(item.associations ?? {})
.filter(([key, mediaItem]) => (
return Object.entries(item.associations || {})
.filter(([key, item]) => (
!key.startsWith('editor_') &&
key !== 'featuremedia' &&
mediaItem != null &&
['video', 'audio'].includes(mediaItem.type)
item != null &&
['video', 'audio'].includes(item.type)
))
.map((args) => args[1]) as IArticle[]; // it's filtering out null values in .filter
.map(([key, item]) => item) as IArticle[]; // null values are filtered in .filter
}

/**
Expand Down Expand Up @@ -129,6 +129,10 @@ export function getThumbnailRendition(picture: IArticle, large?: boolean): IRend
return rendition ?? picture.renditions?.thumbnail;
}

export function notNullOrUndefined<T>(x: null | undefined | T): x is T {
return x != null;
}

export function getImageForList(item: IArticle): {item: IArticle, href: string} | undefined {
const pictures = getPictureList(item);
let thumbnail: IRendition | undefined;
Expand Down
17 changes: 9 additions & 8 deletions newsroom/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from superdesk import get_resource_service
from flask import current_app, render_template, url_for
from flask_babel import gettext
from flask_babel import gettext, force_locale
from flask_mail import Attachment, Message
from jinja2 import TemplateNotFound
from newsroom.auth import get_company
Expand Down Expand Up @@ -204,13 +204,14 @@ def send_template_email(

try:
set_template_locale(language)
send_email(
to=group["emails"],
subject=subject,
text_body=render_template(group["text_template"], **template_kwargs),
html_body=render_template(group["html_template"], **template_kwargs),
**kwargs,
)
with force_locale(language):
send_email(
to=group["emails"],
subject=subject,
text_body=render_template(group["text_template"], **template_kwargs),
html_body=render_template(group["html_template"], **template_kwargs),
**kwargs,
)
finally:
set_template_locale()

Expand Down
14 changes: 12 additions & 2 deletions newsroom/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import newsroom.signals as signals
from copy import copy, deepcopy
from datetime import datetime
from datetime import datetime, timedelta
from typing import Optional, Set

from flask import current_app as app
Expand Down Expand Up @@ -100,7 +100,9 @@ def push():
elif item.get("type") == "text":
orig = superdesk.get_resource_service("items").find_one(req=None, _id=item["guid"])
item["_id"] = publish_item(item, orig)
notify_new_wire_item.delay(item["_id"], check_topics=orig is None)
notify_new_wire_item.delay(
item["_id"], check_topics=orig is None or app.config["WIRE_NOTIFICATIONS_ON_CORRECTIONS"]
)
elif item["type"] == "planning_featured":
publish_planning_featured(item)
else:
Expand Down Expand Up @@ -129,6 +131,12 @@ def publish_item(doc, original):
doc.setdefault("charcount", get_char_count(doc.get("body_html", "")))
doc["original_id"] = doc["guid"]

source_expiry = app.config.get("SOURCE_EXPIRY_DAYS") or {}
if doc.get("source") in source_expiry:
doc["expiry"] = datetime.utcnow().replace(second=0, microsecond=0) + timedelta(
days=source_expiry[doc["source"]]
)

service = superdesk.get_resource_service("content_api")
service.datasource = "items"

Expand All @@ -142,6 +150,8 @@ def publish_item(doc, original):
doc["bookmarks"] = parent_item.get("bookmarks", [])
doc["planning_id"] = parent_item.get("planning_id")
doc["coverage_id"] = parent_item.get("coverage_id")
if parent_item.get("expiry"):
doc["expiry"] = parent_item["expiry"]
else:
logger.warning(
"Failed to find evolvedfrom item %s for %s",
Expand Down
Binary file added newsroom/static/fonts-primereact/primeicons.eot
Binary file not shown.
Loading

0 comments on commit 8e63ecb

Please sign in to comment.