2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-08 08:18:50 +00:00
Matthias Mair fb77158496
Add news reader (#3445)
* add model for feed entries

* add task to update feed entries

* Add API routes

* Fix name in model

* rename model

* fix read endpoint

* reduce duplication in NewsFeed API endpoints

* reduce duplicated code

* add ui elements to index

* add missing migrations

* add ressource route

* add new model to admin

* reorder fields

* format timestamp

* make title linked

* reduce migrations to 1

* fix merge

* fix js style

* add model to ruleset
2022-11-10 12:20:06 +11:00

59 lines
1.5 KiB
JavaScript

{% load i18n %}
{% load inventree_extras %}
/* exported
loadNewsFeedTable,
*/
/*
* Load notification table
*/
function loadNewsFeedTable(table, options={}, enableDelete=false) {
setupFilterList('news', table);
$(table).inventreeTable({
url: options.url,
name: 'news',
groupBy: false,
queryParams: {
ordering: 'published',
},
paginationVAlign: 'bottom',
formatNoMatches: function() {
return '{% trans "No news found" %}';
},
columns: [
{
field: 'pk',
title: '{% trans "ID" %}',
visible: false,
switchable: false,
},
{
field: 'title',
title: '{% trans "Title" %}',
sortable: 'true',
formatter: function(value, row) {
return `<a href="` + row.link + `">` + value + `</a>`;
}
},
{
field: 'summary',
title: '{% trans "Summary" %}',
},
{
field: 'author',
title: '{% trans "Author" %}',
},
{
field: 'published',
title: '{% trans "Published" %}',
sortable: 'true',
formatter: function(value) {
return renderDate(value);
}
},
]
});
}