Revision 58476
Added by Konstantina Galouni almost 4 years ago
update_db.js | ||
---|---|---|
1449 | 1449 |
} |
1450 | 1450 |
} |
1451 | 1451 |
|
1452 |
function createNewPagesForConnect() { |
|
1453 |
// Connect pages |
|
1454 |
publicationsId = db.page.insertOne({ |
|
1455 |
"name": "Publications", |
|
1456 |
"route": "/publications", |
|
1457 |
"type": "other", |
|
1458 |
"connect": true, |
|
1459 |
"openaire": false, |
|
1460 |
"communities": false, |
|
1461 |
"entities": [], |
|
1462 |
"top": true, |
|
1463 |
"bottom": false, |
|
1464 |
"right": false, |
|
1465 |
"left": false |
|
1466 |
}).insertedId.str; |
|
1467 |
print("Connect: Creating Publications page with id " + publicationsId); |
|
1468 |
|
|
1469 |
var connectCommunity = db.community.findOne({pid: "connect"}); |
|
1470 |
connect_pages = connectCommunity.pages; |
|
1471 |
connect_pages[publicationsId] = true; |
|
1472 |
db.community.update({"pid": "connect"}, {$set: {"pages": connect_pages}}); |
|
1473 |
print("Add Publications page with id " + publicationsId + " on community connect"); |
|
1474 |
} |
|
1475 |
|
|
1476 |
function createNewPagesForCommunities() { |
|
1477 |
// Community pages |
|
1478 |
sourcesId = db.page.insertOne({"name" : "Sources and methology", "route" : "/content", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str; |
|
1479 |
print("Communities: Creating Sources and methology page with id " + sourcesId); |
|
1480 |
|
|
1481 |
projectsId = db.page.insertOne({"name" : "Projects and funding opportunities", "route" : "/projects", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str; |
|
1482 |
print("Communities: Creating Projects page with id " + projectsId); |
|
1483 |
|
|
1484 |
nationalBulletinsId = db.page.insertOne({"name" : "National Bulletins", "route" : "/national-bulletins", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str; |
|
1485 |
print("Communities: Creating National Bulletins page with id " + nationalBulletinsId); |
|
1486 |
|
|
1487 |
subjectsId = db.page.insertOne({"name" : "Subjects", "route" : "/subjects", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":true,"right":false,"left":false}).insertedId.str; |
|
1488 |
print("Communities: Creating Subjects page with id " + subjectsId); |
|
1489 |
|
|
1490 |
communities = db.community.find().map( function(community) { return community; } ); |
|
1491 |
for (var i = 0; i < communities.length; i++) { |
|
1492 |
community_pages = communities[i].pages; |
|
1493 |
|
|
1494 |
community_pages[sourcesId] = true; |
|
1495 |
community_pages[projectsId] = false; |
|
1496 |
community_pages[nationalBulletinsId] = false; |
|
1497 |
community_pages[subjectsId] = false; |
|
1498 |
|
|
1499 |
community_pid = communities[i].pid; |
|
1500 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
1501 |
print("Add Sources and methology page with id " + sourcesId + " on community " + community_pid); |
|
1502 |
print("Add Projects page with id " + projectsId + " on community " + community_pid); |
|
1503 |
print("Add National Bulletins page with id " + nationalBulletinsId + " on community " + community_pid); |
|
1504 |
print("Add Subjects page with id " + subjectsId + " on community " + community_pid); |
|
1505 |
} |
|
1506 |
} |
|
1507 |
|
|
1508 |
function removeContentPolicyPageAndAddHelpTextInCommunitiesSourcesPage() { |
|
1509 |
contentId = db.page.find({route: "/content", "connect": true}).map(function (page) { |
|
1510 |
return page._id.str; |
|
1511 |
}).toString(); |
|
1512 |
db.page.remove({"route": "/content", "connect": true}); |
|
1513 |
print("Remove Content Policy page with id " + contentId + " and connect: true"); |
|
1514 |
|
|
1515 |
var connectCommunity = db.community.findOne({pid: "connect"}); |
|
1516 |
// connect_pages = connectCommunity.pages; |
|
1517 |
// delete connect_pages[contentId]; |
|
1518 |
// db.community.update({"pid": "connect"}, {$set: {"pages": connect_pages}}); |
|
1519 |
// print("Remove Content Policy page with id " + contentId + " on community: connect"); |
|
1520 |
|
|
1521 |
communities_contentId = db.page.find({route: "/content", "communities": true}).map(function (page) { |
|
1522 |
return page._id.str; |
|
1523 |
}).toString(); |
|
1524 |
communities = db.community.find().map(function (community) { |
|
1525 |
return community; |
|
1526 |
}); |
|
1527 |
for (var i = 0; i < communities.length; i++) { |
|
1528 |
community_pages = communities[i].pages; |
|
1529 |
delete community_pages[contentId]; |
|
1530 |
db.community.update({"pid": communities[i].pid}, {$set: {"pages": community_pages}}); |
|
1531 |
print("Remove Content Policy page with id " + contentId + " on community: "+communities[i].pid); |
|
1532 |
|
|
1533 |
db.pageHelpContent.find({ |
|
1534 |
community: connectCommunity._id.str, |
|
1535 |
page: contentId |
|
1536 |
}).forEach(function (pageHelpContentForContentPolicy) { |
|
1537 |
if(communities[i].pid != "openaire" && communities[i].pid != "connect") { |
|
1538 |
newCommunityPageHelpContent = db.pageHelpContent.save({ |
|
1539 |
"page": communities_contentId, "community": communities[i]._id.str, |
|
1540 |
"content": pageHelpContentForContentPolicy.content, |
|
1541 |
"placement": pageHelpContentForContentPolicy.placement, "order": pageHelpContentForContentPolicy.order, |
|
1542 |
"isActive": pageHelpContentForContentPolicy.isActive, "isPriorTo": pageHelpContentForContentPolicy.isPriorTo |
|
1543 |
}); |
|
1544 |
|
|
1545 |
print("Add pageHelpContent on community " + communities[i].pid); |
|
1546 |
} |
|
1547 |
}); |
|
1548 |
} |
|
1549 |
|
|
1550 |
pageHelpContentsForContentPolicy = db.pageHelpContent.find({ |
|
1551 |
community: connectCommunity._id.str, |
|
1552 |
page: contentId |
|
1553 |
}).map(function (pageHelpContent) { |
|
1554 |
return pageHelpContent; |
|
1555 |
}); |
|
1556 |
for (var i = 0; i < pageHelpContentsForContentPolicy.length; i++) { |
|
1557 |
db.pageHelpContent.remove({"_id": pageHelpContentsForContentPolicy[i]._id}); |
|
1558 |
print("Removed pageHelpContent with id " + pageHelpContentsForContentPolicy[i]._id.str + " from community: connect"); |
|
1559 |
} |
|
1560 |
} |
|
1561 |
|
|
1452 | 1562 |
use openaire_admin; |
1453 | 1563 |
|
1454 | 1564 |
//updatePages(); |
... | ... | |
1513 | 1623 |
// removeOldLayouts(); |
1514 | 1624 |
|
1515 | 1625 |
// 13-03-2020 |
1516 |
addSearchResearchOutcomesPages(); |
|
1626 |
//addSearchResearchOutcomesPages(); |
|
1627 |
|
|
1628 |
// 10-04-2020 |
|
1629 |
createNewPagesForConnect(); |
|
1630 |
createNewPagesForCommunities(); |
|
1631 |
removeContentPolicyPageAndAddHelpTextInCommunitiesSourcesPage(); |
Also available in: Unified diff
[Trunk | Admin Tools Service]:
1. admintools.properties & UoaAdminToolsApplication.java: Uncomment admintools.properties and ignore if @PropertySource for dnet-override.properties not found, to let tests runs.
2. Subscriber.java: Add default constructor and constructor with email parameter.
3. CommunitySubscribersController.java:
a. Autowire SecurityConfig to let methods get UserInfo via token.
b. Add GET method "getNumberOfSubscribersPerCommunity()" (/community/{pid}/subscribers/count).
c. Add GET methos "getIsSubscribedToCommunity()" (/community/{pid}/is-subscriber): Return true/ false and gets user email via token in @RequestHeader("X-XSRF-TOKEN").
d. Method "addSubscriberInCommunity()" renamed to "addSubscriberInCommunityByEmail()" | Method "deleteSubscriberFromCommunity()" renamed to "deleteSubscriberFromCommunityByEmail()".
e. Add POST methods "addSubscriberInCommunity()" (/community/{pid}/subscriber) and "deleteSubscriberFromCommunity()" (/community/{pid}/subscriber/delete):
Return true/ false and get user email via token in @RequestHeader("X-XSRF-TOKEN").
f. Method getCommunitiesPerSubcriber(@RequestParam(value="email", required = true) String email) --> getCommunitiesPerSubcriber(@RequestHeader("X-XSRF-TOKEN") String token):
Get user email via token in @RequestHeader("X-XSRF-TOKEN").
4. update_db.js:
a. Add method "createNewPagesForConnect()": adds page "/publications" for connect (enabled).
b. Add method "createNewPagesForCommunities()": adds pages "/content" (enabled), "/projects" (disabled), "/national-bulletins" (disabled), "/subjects"(disabled) for communities.
c. Add method "removeContentPolicyPageAndAddHelpTextInCommunitiesSourcesPage()": remove old "/content" connect page and move its contents to new "/content" for every community (NOT connect & openaire).