Skip to content
Snippets Groups Projects
Commit 2b7f7d78 authored by Anatole ROMON's avatar Anatole ROMON
Browse files

migrated and updated seeds

parent 2a8a9029
No related branches found
No related tags found
No related merge requests found
exports.up = async function(knex, Promise) {
await knex.schema.renameTable('question', 'questions');
await knex.schema.renameTable('answer', 'answers');
await knex.schema.renameTable('private_post', 'private_posts');
return;
};
exports.down = async function(knex, Promise) {
await knex.schema.renameTable('questions', 'question');
await knex.schema.renameTable('answers', 'answer');
await knex.schema.renameTable('private_posts', 'private_post');
return;
};
exports.seed = function(knex, Promise) { exports.seed = async function(knex, Promise) {
// Deletes ALL existing entries // Deletes ALL existing entries
return knex('announcements').del() await knex('announcements').del();
.then(function () { await knex('announcements').insert([{
const posts = [{ id: 0,
title: "Fissurer c'est bien", title: "Fissurer c'est bien",
content: "Les nouveaux ordis du JTX sont arrivés ! Le BR aide à les installer ;)", content: "Les nouveaux ordis du JTX sont arrivés ! Le BR aide à les installer ;)"
authors: ['br','jtx'] },{
},{ id: 1,
title: "Proj'et Promotion", title: "Proj'et Promotion",
content: "La nouvelle proj' du JTX arrive !", content: "La nouvelle proj' du JTX arrive !"
authors: ['br'] },{
},{ id: 2,
title: "Fête de la Lune", title: "Fête de la Lune",
content: "C'est bientôt la fête de la Lune ! Inscrivez-vous pour un dîner-spectacle dans le Grand Hall !", content: "C'est bientôt la fête de la Lune ! Inscrivez-vous pour un dîner-spectacle dans le Grand Hall !"
authors: ['x-chine'] },{
},{ id: 3,
title: "Formation Web", title: "Formation Web",
content: "Envie d'apprendre à faire un site Web en Django ? Alors viens en amphi Sauvy ce jeudi à 20h !", content: "Envie d'apprendre à faire un site Web en Django ? Alors viens en amphi Sauvy ce jeudi à 20h !"
authors: ['br'] }]);
}];
return knex('announcements').insert(posts); await knex('events').del()
}); await knex('events').insert([
{
id : 42,
title : "coder sigma",
content : "Tous ensemble pour faire du Dev. Que demander de plus ? (a part du sommeil)",
start_time : knex.fn.now(),
end_time : knex.fn.now(),
is_announcement : false
}
]);
await knex('group_message_relationships').del();
await knex('group_message_relationships').insert([
{
message : 42,
group : 'br',
status : 'host'
},
{
message : 42,
group : 'kes',
status : 'recieve'
}
]);
await knex('group_message_relationships').insert([{
message: 0,
group: 'br',
status: 'host'
},
{
message: 0,
group: 'jtx',
status: 'host'
},
{
message: 1,
group: 'br',
status: 'host'
},
{
message: 2,
group: 'xchine',
status: 'host'
},
{
message: 3,
group: 'br',
status: 'host'
}]);
return;
}; };
exports.seed = async function(knex, Promise) {
// Deletes ALL existing entries
await knex('events').del()
await knex('group_message_relationships').del()
// Inserts seed entries
await knex('events').insert([
{
id : 42,
title : "coder sigma",
content : "Tous ensemble pour faire du Dev. Que demander de plus ? (a part du sommeil)",
start_time : knex.fn.now(),
end_time : knex.fn.now(),
authors : [],
is_announcement : false
}
]);
return knex('group_message_relationships').insert([
{
message : 42,
group : 'br',
status : 'host'
},
{
message : 42,
group : 'kes',
status : 'recieve'
}
]);
};
...@@ -62,7 +62,7 @@ export async function member(user, groupUID){ ...@@ -62,7 +62,7 @@ export async function member(user, groupUID){
let group_list = await selectors.groupsWithMember(user); let group_list = await selectors.groupsWithMember(user);
let test = group_list && await knex.with('group_list', group_list).select().from('group_list').where('uid', groupUID); let test = group_list && await knex.with('group_list', group_list).select().from('group_list').where('uid', groupUID);
if(test && test[0]) if(test && test[0])
return new User(user, null); return new User(user, new UtilisateurAnonyme());
return await admin(user, groupUID); return await admin(user, groupUID);
} }
...@@ -87,7 +87,7 @@ export async function speaker(user, groupUID){ ...@@ -87,7 +87,7 @@ export async function speaker(user, groupUID){
export async function admin(user, groupUID){ export async function admin(user, groupUID){
let adminList = await list_selectors.usersWithAdminRights(user, groupUID); let adminList = await list_selectors.usersWithAdminRights(user, groupUID);
if (typeof adminList != "undefined" && adminList.indexOf(user.uid) != -1) if (typeof adminList != "undefined" && adminList.indexOf(user.uid) != -1)
return new User(user, null); return new User(user, new UtilisateurAnonyme());
} }
/** /**
......
...@@ -17,7 +17,13 @@ import * as authentifiers from './connectors/authentifiers'; ...@@ -17,7 +17,13 @@ import * as authentifiers from './connectors/authentifiers';
* @description Résolveurs des différentes requêtes GraphQL * @description Résolveurs des différentes requêtes GraphQL
*/ */
// ceci est un test function ChevalierError(err){
this.returned_error = err;
this.name = "chevalier error";
this.message = "Error encountered while running ldap access code : " + err.message;
this.toString = () => this.message;
}
export const resolvers = { export const resolvers = {
// @rights user // @rights user
...@@ -318,7 +324,7 @@ export const resolvers = { ...@@ -318,7 +324,7 @@ export const resolvers = {
admins: async function(obj, args, context){ admins: async function(obj, args, context){
let user = await authentifiers.member(context.user, obj.uid); let user = await authentifiers.member(context.user, obj.uid);
return user.ldap_access.listMembers(context.user,obj.uid); return await user.ldap_access.listMembers(context.user,obj.uid);
}, },
members: async function(obj, args, context){ members: async function(obj, args, context){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment