@saltcorn/server 0.8.6-beta.1 → 0.8.6-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +3 -3
- package/auth/admin.js +4 -0
- package/auth/roleadmin.js +7 -4
- package/auth/routes.js +1 -1
- package/errors.js +1 -1
- package/locales/en.json +16 -2
- package/locales/pl.json +1 -1
- package/locales/ru.json +38 -2
- package/locales/uk.json +1170 -0
- package/package.json +8 -8
- package/public/dayjs.min.js +1 -0
- package/public/saltcorn-common.js +97 -69
- package/public/saltcorn.css +17 -0
- package/public/saltcorn.js +3 -3
- package/routes/admin.js +26 -0
- package/routes/api.js +27 -48
- package/routes/common_lists.js +4 -1
- package/routes/delete.js +3 -3
- package/routes/edit.js +1 -1
- package/routes/fields.js +32 -12
- package/routes/files.js +7 -7
- package/routes/homepage.js +3 -3
- package/routes/index.js +4 -41
- package/routes/menu.js +1 -1
- package/routes/page.js +2 -2
- package/routes/pageedit.js +2 -2
- package/routes/scapi.js +1 -1
- package/routes/search.js +4 -5
- package/routes/sync.js +84 -0
- package/routes/tables.js +5 -5
- package/routes/tenant.js +74 -27
- package/routes/view.js +3 -3
- package/routes/viewedit.js +43 -15
- package/tests/admin.test.js +8 -8
- package/tests/auth.test.js +13 -13
- package/tests/crud.test.js +2 -2
- package/tests/files.test.js +6 -6
- package/tests/kittens.test.js +11 -11
- package/tests/page.test.js +4 -5
- package/tests/sync.test.js +108 -0
- package/tests/table.test.js +6 -6
- package/tests/tenant.test.js +3 -3
- package/tests/view.test.js +128 -1
- package/tests/viewedit.test.js +4 -4
- package/wrapper.js +3 -2
package/tests/tenant.test.js
CHANGED
|
@@ -27,7 +27,7 @@ describe("tenant routes", () => {
|
|
|
27
27
|
if (!db.isSQLite) {
|
|
28
28
|
it("shows create form", async () => {
|
|
29
29
|
db.enable_multi_tenant();
|
|
30
|
-
await getState().setConfig("role_to_create_tenant", "
|
|
30
|
+
await getState().setConfig("role_to_create_tenant", "100");
|
|
31
31
|
|
|
32
32
|
const app = await getApp({ disableCsrf: true });
|
|
33
33
|
await request(app).get("/tenant/create").expect(toInclude("subdomain"));
|
|
@@ -43,7 +43,7 @@ describe("tenant routes", () => {
|
|
|
43
43
|
|
|
44
44
|
it("creates tenant with capital letter", async () => {
|
|
45
45
|
db.enable_multi_tenant();
|
|
46
|
-
await getState().setConfig("role_to_create_tenant", "
|
|
46
|
+
await getState().setConfig("role_to_create_tenant", "100");
|
|
47
47
|
|
|
48
48
|
const app = await getApp({ disableCsrf: true });
|
|
49
49
|
await request(app)
|
|
@@ -55,7 +55,7 @@ describe("tenant routes", () => {
|
|
|
55
55
|
|
|
56
56
|
it("rejects existing tenant", async () => {
|
|
57
57
|
db.enable_multi_tenant();
|
|
58
|
-
await getState().setConfig("role_to_create_tenant", "
|
|
58
|
+
await getState().setConfig("role_to_create_tenant", "100");
|
|
59
59
|
const app = await getApp({ disableCsrf: true });
|
|
60
60
|
await request(app)
|
|
61
61
|
.post("/tenant/create")
|
package/tests/view.test.js
CHANGED
|
@@ -99,7 +99,7 @@ describe("view with routes", () => {
|
|
|
99
99
|
name: "aviewwithroutes",
|
|
100
100
|
viewtemplate: "ViewWithRoutes",
|
|
101
101
|
configuration: {},
|
|
102
|
-
min_role:
|
|
102
|
+
min_role: 80,
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
it("should redirect if not auth", async () => {
|
|
@@ -177,3 +177,130 @@ describe("render view with slug", () => {
|
|
|
177
177
|
.expect(toInclude(`Herman Melville`));
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
|
+
|
|
181
|
+
describe("inbound relations", () => {
|
|
182
|
+
it("view with inbound relation", async () => {
|
|
183
|
+
const app = await getApp({ disableCsrf: true });
|
|
184
|
+
const loginCookie = await getAdminLoginCookie();
|
|
185
|
+
await request(app)
|
|
186
|
+
.get("/view/show_user_with_blog_posts_feed?id=1")
|
|
187
|
+
.set("Cookie", loginCookie)
|
|
188
|
+
.expect(toInclude("Content of post APost A"))
|
|
189
|
+
.expect(toInclude("Content of post BPost B"))
|
|
190
|
+
.expect(toInclude("Content of post CPost C"));
|
|
191
|
+
|
|
192
|
+
await request(app)
|
|
193
|
+
.get("/view/show_user_with_blog_posts_feed?id=2")
|
|
194
|
+
.set("Cookie", loginCookie)
|
|
195
|
+
.expect(toNotInclude("Content of post APost A"))
|
|
196
|
+
.expect(toInclude("Content of post BPost B"))
|
|
197
|
+
.expect(toNotInclude("Content of post CPost C"));
|
|
198
|
+
|
|
199
|
+
await request(app)
|
|
200
|
+
.get("/view/show_user_with_blog_posts_feed?id=3")
|
|
201
|
+
.set("Cookie", loginCookie)
|
|
202
|
+
.expect(toInclude("Content of post APost A"))
|
|
203
|
+
.expect(toInclude("Content of post BPost B"))
|
|
204
|
+
.expect(toInclude("Content of post CPost C"));
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("view without inbound relation", async () => {
|
|
208
|
+
const app = await getApp({ disableCsrf: true });
|
|
209
|
+
const loginCookie = await getAdminLoginCookie();
|
|
210
|
+
await request(app)
|
|
211
|
+
.get("/view/show_user_with_independent_feed?id=1")
|
|
212
|
+
.set("Cookie", loginCookie)
|
|
213
|
+
.expect(toInclude("Content of post APost A"))
|
|
214
|
+
.expect(toInclude("Content of post BPost B"))
|
|
215
|
+
.expect(toInclude("Content of post CPost C"));
|
|
216
|
+
await request(app)
|
|
217
|
+
.get("/view/show_user_with_independent_feed?id=2")
|
|
218
|
+
.set("Cookie", loginCookie)
|
|
219
|
+
.expect(toInclude("Content of post APost A"))
|
|
220
|
+
.expect(toInclude("Content of post BPost B"))
|
|
221
|
+
.expect(toInclude("Content of post CPost C"));
|
|
222
|
+
await request(app)
|
|
223
|
+
.get("/view/show_user_with_independent_feed?id=3")
|
|
224
|
+
.set("Cookie", loginCookie)
|
|
225
|
+
.expect(toInclude("Content of post APost A"))
|
|
226
|
+
.expect(toInclude("Content of post BPost B"))
|
|
227
|
+
.expect(toInclude("Content of post CPost C"));
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("inbound relation from query", async () => {
|
|
231
|
+
const queryObj = {
|
|
232
|
+
relation:
|
|
233
|
+
".users.user_interested_in_topic$user.topic.blog_in_topic$topic.post",
|
|
234
|
+
srcId: 1,
|
|
235
|
+
};
|
|
236
|
+
const app = await getApp({ disableCsrf: true });
|
|
237
|
+
const loginCookie = await getAdminLoginCookie();
|
|
238
|
+
|
|
239
|
+
await request(app)
|
|
240
|
+
.get(
|
|
241
|
+
`/view/blog_posts_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
242
|
+
JSON.stringify(queryObj)
|
|
243
|
+
)}`
|
|
244
|
+
)
|
|
245
|
+
.set("Cookie", loginCookie)
|
|
246
|
+
.expect(toInclude("Content of post APost A"))
|
|
247
|
+
.expect(toInclude("Content of post BPost B"))
|
|
248
|
+
.expect(toInclude("Content of post CPost C"));
|
|
249
|
+
|
|
250
|
+
queryObj.srcId = 2;
|
|
251
|
+
await request(app)
|
|
252
|
+
.get(
|
|
253
|
+
`/view/blog_posts_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
254
|
+
JSON.stringify(queryObj)
|
|
255
|
+
)}`
|
|
256
|
+
)
|
|
257
|
+
.set("Cookie", loginCookie)
|
|
258
|
+
.expect(toNotInclude("Content of post APost A"))
|
|
259
|
+
.expect(toInclude("Content of post BPost B"))
|
|
260
|
+
.expect(toNotInclude("Content of post CPost C"));
|
|
261
|
+
|
|
262
|
+
queryObj.srcId = 3;
|
|
263
|
+
await request(app)
|
|
264
|
+
.get(
|
|
265
|
+
`/view/blog_posts_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
266
|
+
JSON.stringify(queryObj)
|
|
267
|
+
)}`
|
|
268
|
+
)
|
|
269
|
+
.set("Cookie", loginCookie)
|
|
270
|
+
.expect(toInclude("Content of post APost A"))
|
|
271
|
+
.expect(toInclude("Content of post BPost B"))
|
|
272
|
+
.expect(toInclude("Content of post CPost C"));
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("inbound relation with levels from query", async () => {
|
|
276
|
+
const queryObj = {
|
|
277
|
+
relation:
|
|
278
|
+
".users.user_interested_in_topic$user.topic.inbound_inbound$topic.bp_inbound.post",
|
|
279
|
+
srcId: 1,
|
|
280
|
+
};
|
|
281
|
+
const app = await getApp({ disableCsrf: true });
|
|
282
|
+
const loginCookie = await getAdminLoginCookie();
|
|
283
|
+
await request(app)
|
|
284
|
+
.get(
|
|
285
|
+
`/view/blog_posts_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
286
|
+
JSON.stringify(queryObj)
|
|
287
|
+
)}`
|
|
288
|
+
)
|
|
289
|
+
.set("Cookie", loginCookie)
|
|
290
|
+
.expect(toInclude("Content of post APost A"))
|
|
291
|
+
.expect(toNotInclude("Content of post BPost B"))
|
|
292
|
+
.expect(toInclude("Content of post CPost C"));
|
|
293
|
+
|
|
294
|
+
queryObj.srcId = 2;
|
|
295
|
+
await request(app)
|
|
296
|
+
.get(
|
|
297
|
+
`/view/blog_posts_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
298
|
+
JSON.stringify(queryObj)
|
|
299
|
+
)}`
|
|
300
|
+
)
|
|
301
|
+
.set("Cookie", loginCookie)
|
|
302
|
+
.expect(toNotInclude("Content of post APost A"))
|
|
303
|
+
.expect(toNotInclude("Content of post BPost B"))
|
|
304
|
+
.expect(toNotInclude("Content of post CPost C"));
|
|
305
|
+
});
|
|
306
|
+
});
|
package/tests/viewedit.test.js
CHANGED
|
@@ -53,7 +53,7 @@ describe("viewedit edit endpoint", () => {
|
|
|
53
53
|
.send("table_name=books")
|
|
54
54
|
.send("id=" + v.id)
|
|
55
55
|
.send("name=authorlist")
|
|
56
|
-
.send("min_role=
|
|
56
|
+
.send("min_role=100")
|
|
57
57
|
.set("Cookie", loginCookie)
|
|
58
58
|
.expect(toRedirect("/viewedit/config/authorlist"));
|
|
59
59
|
});
|
|
@@ -95,7 +95,7 @@ describe("viewedit new List", () => {
|
|
|
95
95
|
.send("viewtemplate=List")
|
|
96
96
|
.send("table_name=books")
|
|
97
97
|
.send("name=mybooklist")
|
|
98
|
-
.send("min_role=
|
|
98
|
+
.send("min_role=80")
|
|
99
99
|
.set("Cookie", loginCookie)
|
|
100
100
|
.expect(toRedirect("/viewedit/config/mybooklist"));
|
|
101
101
|
//expect(res.text.includes("View configuration")).toBe(true);
|
|
@@ -212,7 +212,7 @@ describe("viewedit new List with one field", () => {
|
|
|
212
212
|
.send("viewtemplate=List")
|
|
213
213
|
.send("table_name=books")
|
|
214
214
|
.send("name=mybooklist1")
|
|
215
|
-
.send("min_role=
|
|
215
|
+
.send("min_role=80")
|
|
216
216
|
.set("Cookie", loginCookie)
|
|
217
217
|
.expect(toRedirect("/viewedit/config/mybooklist1"));
|
|
218
218
|
//expect(res.text.includes("View configuration")).toBe(true);
|
|
@@ -334,7 +334,7 @@ describe("viewedit new Show", () => {
|
|
|
334
334
|
.send("viewtemplate=Show")
|
|
335
335
|
.send("table_name=books")
|
|
336
336
|
.send("name=mybook")
|
|
337
|
-
.send("min_role=
|
|
337
|
+
.send("min_role=80")
|
|
338
338
|
.set("Cookie", loginCookie)
|
|
339
339
|
.expect(toRedirect("/viewedit/config/mybook"));
|
|
340
340
|
//expect(res.text.includes("View configuration")).toBe(true);
|
package/wrapper.js
CHANGED
|
@@ -27,7 +27,7 @@ const getFlashes = (req) =>
|
|
|
27
27
|
const get_menu = (req) => {
|
|
28
28
|
const isAuth = req.user && req.user.id;
|
|
29
29
|
const state = getState();
|
|
30
|
-
const role = (req.user || {}).role_id ||
|
|
30
|
+
const role = (req.user || {}).role_id || 100;
|
|
31
31
|
|
|
32
32
|
const allow_signup = state.getConfig("allow_signup");
|
|
33
33
|
const notification_in_menu = state.getConfig("notification_in_menu");
|
|
@@ -192,6 +192,7 @@ const get_headers = (req, version_tag, description, extras = []) => {
|
|
|
192
192
|
{ css: `/static_assets/${version_tag}/saltcorn.css` },
|
|
193
193
|
{ script: `/static_assets/${version_tag}/saltcorn-common.js` },
|
|
194
194
|
{ script: `/static_assets/${version_tag}/saltcorn.js` },
|
|
195
|
+
{ script: `/static_assets/${version_tag}/dayjs.min.js` },
|
|
195
196
|
];
|
|
196
197
|
let from_cfg = [];
|
|
197
198
|
if (state.getConfig("page_custom_css", ""))
|
|
@@ -245,7 +246,7 @@ module.exports = (version_tag) =>
|
|
|
245
246
|
* @param next
|
|
246
247
|
*/
|
|
247
248
|
function (req, res, next) {
|
|
248
|
-
const role = (req.user || {}).role_id ||
|
|
249
|
+
const role = (req.user || {}).role_id || 100;
|
|
249
250
|
|
|
250
251
|
res.sendAuthWrap = function (title, form, authLinks, ...html) {
|
|
251
252
|
const state = getState();
|