Skip to content

Commit f96a6e6

Browse files
authored
Merge pull request #306 from the-good-boy/adminLogs
feat(Admin-logs): AdminLog Model
2 parents e4a06d7 + af0a2e8 commit f96a6e6

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import * as util from './util'; // eslint-disable-line import/no-namespace
2222
import Bookshelf from '@metabrainz/bookshelf';
2323
import achievementType from './models/achievementType';
2424
import achievementUnlock from './models/achievementUnlock';
25+
import adminLog from './models/adminLog';
2526
import alias from './models/alias';
2627
import aliasSet from './models/aliasSet';
2728
import annotation from './models/annotation';
@@ -117,6 +118,7 @@ export default function init(config) {
117118
return {
118119
AchievementType: achievementType(bookshelf),
119120
AchievementUnlock: achievementUnlock(bookshelf),
121+
AdminLog: adminLog(bookshelf),
120122
Alias: alias(bookshelf),
121123
AliasSet: aliasSet(bookshelf),
122124
Annotation: annotation(bookshelf),

src/models/adminLog.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2023 Shivam Awasthi
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program; if not, write to the Free Software Foundation, Inc.,
16+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17+
*/
18+
19+
20+
import {camelToSnake, snakeToCamel} from '../util';
21+
22+
23+
export default function adminLog(bookshelf) {
24+
const AdminLog = bookshelf.Model.extend({
25+
admin() {
26+
return this.belongsTo('Editor', 'admin_id');
27+
},
28+
format: camelToSnake,
29+
idAttribute: 'id',
30+
parse: snakeToCamel,
31+
tableName: 'bookbrainz.admin_log',
32+
targetUser() {
33+
return this.belongsTo('Editor', 'target_user_id');
34+
}
35+
});
36+
37+
return bookshelf.model('AdminLog', AdminLog);
38+
}
39+

0 commit comments

Comments
 (0)