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

Update master to be inline with 1.33 #854

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
049e004
Update Superdesk to v1.32.x
MarkLark86 Feb 10, 2020
9ad00c8
Set the Analytics version
marwoodandrew Jun 11, 2020
fada920
fix(fulfill assignments) fix moving photo assignments from in progres…
marwoodandrew Apr 19, 2020
5ac48f4
fix(daylight savings) it seems that the test has a summer and winter …
marwoodandrew Mar 31, 2020
56063c3
Merge pull request #837 from marwoodandrew/set-analytics-version
marwoodandrew Jun 11, 2020
fda345a
Updating to 1.33
marwoodandrew Jun 25, 2020
57514bd
Merge pull request #838 from marwoodandrew/1.33
marwoodandrew Jun 29, 2020
0528ff3
fix(sports locator) set headline prfix to sport if category is sport …
marwoodandrew Mar 31, 2020
a8c90d2
fix(golf macro) missing region and sort order (#822)
marwoodandrew Feb 13, 2020
fa83b94
fix(racing macro) set the genre in the selections based on the genre …
marwoodandrew Feb 13, 2020
ba1979f
[SDESK-4864] Macro to process incomming acceptance email (#829)
marwoodandrew Feb 27, 2020
be9b34f
[SDESK-5023] Use display name 'NBA' for iptc subject code 15008001 (#…
MarkLark86 Feb 23, 2020
0a426bd
[SDESK-5072] Enable config option PLANNING_USE_XMP_FOR_PIC_SLUGLINE (…
MarkLark86 Mar 3, 2020
dad0caf
[SDESK-4863] Implement an Assignment Email layout that allows 'accept…
nrvikas Feb 21, 2020
fd88021
[SDESK-4863] Fix spaces in assignment acceptance email on gmail mobil…
MarkLark86 Mar 9, 2020
772ebea
Merge pull request #839 from marwoodandrew/cherry-pick
marwoodandrew Jul 1, 2020
7bda11a
fix(procs) Add missing ingest proc and rename test base class file
marwoodandrew Jul 1, 2020
42e00dc
Merge pull request #840 from marwoodandrew/fix-procs
marwoodandrew Jul 1, 2020
f3b6874
fix(analytics) update to for changes in analytics
marwoodandrew Jul 6, 2020
3011f97
Merge pull request #841 from marwoodandrew/fix-analytics
marwoodandrew Jul 6, 2020
bb1c22c
fix(racing macro) change footer to mediality
marwoodandrew Aug 5, 2020
f1464c3
fix(golf) stop duplication of events in output
marwoodandrew Aug 18, 2020
17b7ca9
Enable publish button in edit page
marwoodandrew Sep 2, 2020
ad94659
Merge pull request #842 from marwoodandrew/mediality-macro
marwoodandrew Sep 8, 2020
c233351
Merge pull request #843 from marwoodandrew/fix-golf
marwoodandrew Sep 8, 2020
ea4dba1
Merge pull request #845 from marwoodandrew/publish-button
marwoodandrew Sep 8, 2020
12b6ca9
Set library version to released versions
marwoodandrew Sep 7, 2020
738f1fc
Merge pull request #846 from marwoodandrew/set-versions
marwoodandrew Sep 8, 2020
e9b3561
Update client core
marwoodandrew Sep 10, 2020
188f1de
Bump analytics version
marwoodandrew Sep 16, 2020
2652474
Merge pull request #847 from marwoodandrew/bump-analytics
marwoodandrew Sep 16, 2020
196594b
Set released version of analytics
marwoodandrew Sep 21, 2020
5b3f369
Set editor2 config entirely in server
marwoodandrew Sep 21, 2020
b89a9d1
Merge pull request #848 from marwoodandrew/bump-analytics
marwoodandrew Sep 21, 2020
5822f18
Golf and BOB formatter patches
marwoodandrew Oct 7, 2020
cbef50e
Merge pull request #851 from marwoodandrew/patches
marwoodandrew Oct 7, 2020
cd8ab94
Update depenedencies
marwoodandrew Oct 7, 2020
6f90f8d
Merge pull request #852 from marwoodandrew/bump-depends
marwoodandrew Oct 7, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ MissionReportController.$inject = [
'savedReports',
'notify',
'lodash',
'searchReport',
'$q',
'missionReportChart',
'reportConfigs',
Expand All @@ -19,7 +18,6 @@ MissionReportController.$inject = [
* @requires savedReports
* @requires notify
* @requires lodash
* @requires searchReport
* @requires $q
* @requires missionReportChart
* @requires reportConfigs
Expand All @@ -30,7 +28,6 @@ export function MissionReportController(
savedReports,
notify,
_,
searchReport,
$q,
missionReportChart,
reportConfigs
Expand Down
19 changes: 7 additions & 12 deletions client/aap/sms_report/controllers/SMSReportController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ import {getErrorMessage, getUtcOffsetInMinutes} from 'superdesk-analytics/client
import {DATE_FILTERS} from 'superdesk-analytics/client/search/common';
import {CHART_FIELDS, CHART_TYPES} from 'superdesk-analytics/client/charts/directives/ChartOptions';
import {SDChart} from 'superdesk-analytics/client/charts/SDChart';
import {searchReportService} from 'superdesk-analytics/client/search/services/SearchReport';
import {appConfig} from 'superdesk-core/scripts/appConfig';

SMSReportController.$inject = [
'$scope',
'savedReports',
'chartConfig',
'lodash',
'searchReport',
'moment',
'notify',
'gettext',
'$q',
'config',
'deployConfig',
'reportConfigs',
];

Expand All @@ -24,13 +23,10 @@ export function SMSReportController(
savedReports,
chartConfig,
_,
searchReport,
moment,
notify,
gettext,
$q,
config,
deployConfig,
reportConfigs
) {
const reportName = 'sms_report';
Expand All @@ -57,7 +53,7 @@ export function SMSReportController(
};

this.initDefaultParams = () => {
$scope.item_states = searchReport.filterItemStates(
$scope.item_states = searchReportService.filterItemStates(
['published', 'killed', 'corrected', 'recalled']
);

Expand All @@ -79,8 +75,8 @@ export function SMSReportController(
filter: DATE_FILTERS.RANGE,
start: moment()
.subtract(30, 'days')
.format(config.model.dateformat),
end: moment().format(config.model.dateformat),
.format(appConfig.model.dateformat),
end: moment().format(appConfig.model.dateformat),
},
must: {},
must_not: {},
Expand Down Expand Up @@ -206,16 +202,15 @@ export function SMSReportController(
// Any data after the daylight savings change will be 1 hour out
const utcOffset = getUtcOffsetInMinutes(
report['start'],
config.defaultTimezone,
moment
appConfig.defaultTimezone
);

const chart = new SDChart.Chart({
id: reportName,
chartType: 'highcharts',
title: $scope.generateTitle(),
subtitle: $scope.generateSubtitle(),
startOfWeek: deployConfig.getSync('start_of_week', 0),
startOfWeek: appConfig.start_of_week || appConfig.startingDay || 0,
timezoneOffset: utcOffset,
useUTC: false,
fullHeight: true,
Expand Down
12 changes: 12 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {startApp} from 'superdesk-core/scripts/index';
import planningExtension from 'superdesk-planning/client/planning-extension/dist/extension';
import './aap/index.js';

setTimeout(() => {
startApp(
[planningExtension],
{},
);
});

export default angular.module('main.superdesk', []);
6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "superdesk",
"license": "GPL-3.0",
"dependencies": {
"superdesk-core": "superdesk/superdesk-client-core#1.31",
"superdesk-planning": "superdesk/superdesk-planning#master",
"superdesk-analytics": "superdesk/superdesk-analytics#master"
"superdesk-core": "1.33.5",
"superdesk-planning": "1.33.1",
"superdesk-analytics": "1.33.4"
}
}
18 changes: 7 additions & 11 deletions client/superdesk.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function() {
module.exports = function(grunt) {
return {
apps: ['superdesk-planning', 'superdesk.analytics', 'aap.apps'],
importApps: ['superdesk-planning', 'superdesk-analytics', '../aap'],
importApps: ['superdesk-planning', 'superdesk-analytics', '../index.js'],
defaultRoute: '/workspace',
workspace: {
ingest: 1,
Expand All @@ -19,15 +19,6 @@ module.exports = function() {
change_profile: 1
},

editor: {
toolbar: false,
embeds: false,
paste: {
forcePlainText: true,
cleanPastedHTML: false
}
},

features: {
elasticHighlight: 1,
swimlane: {defaultNumberOfColumns: 4},
Expand All @@ -45,6 +36,11 @@ module.exports = function() {
editorInlineComments: false,
editorSuggestions: false,
validatePointOfInterestForImages: true,
customAuthoringTopbar: {
toDesk: false,
publish: false,
publishAndContinue: false,
}
},

activity: {
Expand Down
1 change: 1 addition & 0 deletions server/Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ work: celery -A worker -Q default worker
expiry: celery -A worker -Q expiry worker
legal: celery -A worker -Q legal worker
publish: celery -A worker -Q publish worker
ingest: celery -A worker -Q ingest worker
beat: celery -A worker beat --pid=
capi: gunicorn -b 0.0.0.0:5400 -c gunicorn_config.py content_api.wsgi
highcharts: python3 -u -m analytics.reports.highcharts_server
131 changes: 112 additions & 19 deletions server/aap/commands/fulfill_image_assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
from superdesk.utc import utcnow, utc_to_local
from datetime import timedelta
from planning.common import ASSIGNMENT_WORKFLOW_STATE
from planning.assignments.assignments_history import ASSIGNMENT_HISTORY_ACTIONS
from eve.utils import ParsedRequest
from flask import json
from flask import current_app as app
import requests
from lxml import etree
from superdesk.celery_task_utils import get_lock_id
from superdesk.lock import lock, unlock
from copy import deepcopy
from eve.utils import config
from bson import ObjectId

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -110,8 +114,8 @@ def _get_dc_images_by_field(self, archive, value):
logger.error('DC login failed')
retries += 1
if retries == 3:
logger.error('Failed to get image by field from DC {}'.format(id))
return None
logger.error('Failed to get image by field from DC {}'.format(id))
return etree.fromstring(response.content)

def _get_outstanding_photo_assignments(self):
Expand All @@ -120,10 +124,43 @@ def _get_outstanding_photo_assignments(self):
:return: The Id of any sheduled picure assignments
"""
service = superdesk.get_resource_service('assignments')
assignments = service.find(where={"assigned_to.state": ASSIGNMENT_WORKFLOW_STATE.ASSIGNED,
"planning.g2_content_type": "picture",
"planning.scheduled": {"$gte": utcnow() - timedelta(days=2)},
"lock_user": None})
query = {
'query': {
'bool': {
'must': [
{
'terms': {
'assigned_to.state': [
ASSIGNMENT_WORKFLOW_STATE.ASSIGNED,
ASSIGNMENT_WORKFLOW_STATE.IN_PROGRESS
]
}
},
{
'term': {
'planning.g2_content_type': 'picture'
}
},
{
'range': {
'planning.scheduled': {
'gte': 'now-2d'
}
}
}
],
'must_not': {
'exists': {
'field': 'lock_user'
}
}
}
}
}
req = ParsedRequest()
req.args = {'source': json.dumps(query)}

assignments = service.get(req=req, lookup=None)
if assignments.count() > 0:
logger.warning('Found {} outstanding assignments in planning'.format(assignments.count()))
else:
Expand Down Expand Up @@ -183,28 +220,80 @@ def _get_image_modifier(self, assignment):
# return the assignor user or the assignor desk, if nothing else available
return {'proxy_user': assigned_to.get('assignor_user', assigned_to.get('assignor_desk'))}

def _check_in_progress(self, assignments):
def _extract_user(self, image):
"""
Given an image dossier extract the user that modified it
:param image:
:return:
"""
dossier = image.find('./dc_rest_docs/dc_rest_doc/dcdossier')
if dossier is not None:
modified_by = dossier.attrib.get('modified_by')
if modified_by is not None and not modified_by == 'system':
user_service = superdesk.get_resource_service('users')
user = user_service.find_one(req=None, username=modified_by)
if user:
return user
return None

def _check_in_progress(self, assignments, complete):
"""
Check the AAP Image Pool for any assignments that may be in progress
:param assignments:
:return:
"""
in_progress_assignments = list()
in_list = set()
for assignment in assignments:
# look in the AAP Image pool
dc_images = self._get_dc_images_by_field('aapimage', assignment.get('_id'))
if dc_images:
count = dc_images.find('./doc_count')
if count and int(count.text) > 0:
in_progress_assignments.append(assignment)
# If we have marked the assignment complete ignore it
if assignment.get('_id') in complete:
continue
if assignment.get('assigned_to', {}).get('state') == ASSIGNMENT_WORKFLOW_STATE.ASSIGNED:
# look in the AAP Image pool
dc_images = self._get_dc_images_by_field('aapimage', assignment.get('_id'))
if dc_images is not None:
count = dc_images.find('./doc_count')
if count is not None and int(count.text) > 0:
logger.info('Found in progress items in aapimage for {}'.format(assignment.get('_id')))
user = self._extract_user(dc_images)
in_list.add(assignment.get('_id'))
in_progress_assignments.append({'assignment': assignment, 'user': user})
continue
# look in the picedit pool
dc_images = self._get_dc_images_by_field('picedit', assignment.get('_id'))
if dc_images is not None:
count = dc_images.find('./doc_count')
if count is not None and int(count.text) > 0:
logger.info('Found in progress items in picedit for {}'.format(assignment.get('_id')))
user = self._extract_user(dc_images)
if assignment.get('_id') not in in_list:
in_list.add(assignment.get('_id'))
in_progress_assignments.append({'assignment': assignment, 'user': user})
return in_progress_assignments

def _mark_as_in_progress(self, assignments):
"""
TODO
Set the assignment state for that passed assignments to in progress
:param assignments:
:return:
"""
pass
service = superdesk.get_resource_service('assignments')
for assignment in assignments:
logger.warning('Marking assignment {} in progress'.format(assignment.get('assignment').get('_id')))
assignment.get('assignment')[config.ID_FIELD] = ObjectId(assignment.get('assignment')[config.ID_FIELD])
assigned_to = assignment.get('assignment').get('assigned_to')
updates = {'assigned_to': deepcopy(assigned_to)}
updates['assigned_to']['state'] = ASSIGNMENT_WORKFLOW_STATE.IN_PROGRESS
try:
service.patch(assignment.get('assignment')[config.ID_FIELD], updates)
if assignment.get('user') is None:
updates['proxy_user'] = assigned_to.get('assignor_user', assigned_to.get('assignor_desk'))
else:
updates['proxy_user'] = assignment.get('user').get(config.ID_FIELD)
superdesk.get_resource_service('assignments_history').on_item_updated(
updates, assignment.get('assignment'), ASSIGNMENT_HISTORY_ACTIONS.START_WORKING)
except Exception as ex:
logger.exception(ex)

def _mark_as_complete(self, assignments):
"""
Expand All @@ -216,8 +305,8 @@ def _mark_as_complete(self, assignments):
for assignment in assignments:
user = self._get_image_modifier(assignment)
try:
logger.info('Marking assignment {} as complete'.format(assignment.get('assignment').get('_id')))
service.patch(assignment.get('assignment').get('_id'), user)
logger.warning('Marking assignment {} as complete'.format(assignment.get('assignment').get('_id')))
service.patch(ObjectId(assignment.get('assignment').get('_id')), user)
except Exception as ex:
logger.exception(ex)

Expand All @@ -230,15 +319,19 @@ def run(self, ):
return

# Get a list of the outstanding photo assignments
assignments = self._get_outstanding_photo_assignments()
assignments = list(self._get_outstanding_photo_assignments())

# query for any images available from the image site API with those assigment id's
completed_assignments = self._check_complete(assignments)

self._mark_as_complete(completed_assignments)

# assignments.rewind()
# in_progress_assignments = self._check_in_progress(assignments)
complete = [c.get('assignment').get('_id') for c in completed_assignments]

# check if any of the outstanding assignments are in either the picedit or aapimage pools
in_progress_assignments = self._check_in_progress(assignments, complete)

self._mark_as_in_progress(in_progress_assignments)

unlock(lock_name)
logger.info('Finished fulfilling assignments')
Expand Down
3 changes: 2 additions & 1 deletion server/aap/io/data/aap_subject_codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@
"15072008":"69 kg - wrestling",
"15072009":"63 kg - wrestling",
"15077008":"freestyle - flying disc",
"15008001": "NBA",
"01028000":"history - arts, culture and entertainment",
"04002001":"biotechnology - chemicals",
"04007003":"food - consumer goods",
"04008002":"consumer issue - macro economics",
"04013002":"food - process industry",
"04016034":"privatisation - company information",
"08003000":"people - human interest"
}
}
2 changes: 1 addition & 1 deletion server/aap/io/feed_parsers/aap_sportsfixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def _set_location(self, item, location_string):
location['original_source'] = 'AAP Sports Results'
location['position'] = {'longitude': stadium.point.longitude, 'latitude': stadium.point.latitude,
'altitude': stadium.point.altitude}
localities = [l for l in self.localityHierarchy if stadium.raw.get('address', {}).get(l)]
localities = [local for local in self.localityHierarchy if stadium.raw.get('address', {}).get(local)]
areas = [a for a in self.areaHierarchy if stadium.raw.get('address', {}).get(a)]
line = stadium.raw.get('address', {}).get('house_number', '')
line = stadium.raw.get('address', {}).get('road', '') if line == '' else \
Expand Down
Loading