hotLine work
This commit is contained in:
parent
6c77008d47
commit
cc0a5ec15c
5 changed files with 87 additions and 42 deletions
2
main.js
2
main.js
|
@ -26,6 +26,8 @@ app.use(authMiddleware);
|
||||||
app.use(demoRoutes);
|
app.use(demoRoutes);
|
||||||
app.use(authRoutes);
|
app.use(authRoutes);
|
||||||
app.use(postsRoutes);
|
app.use(postsRoutes);
|
||||||
|
app.use('/images', express.static(path.join(__dirname, 'images')));
|
||||||
|
|
||||||
|
|
||||||
app.use(function(error, req, res, next) {
|
app.use(function(error, req, res, next) {
|
||||||
res.render('500');
|
res.render('500');
|
||||||
|
|
|
@ -82,24 +82,32 @@ router.post('/submitResolution/:postId', upload.single('image'), async function
|
||||||
prenom: prenom,
|
prenom: prenom,
|
||||||
imagePath: path
|
imagePath: path
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter = {id: postId};
|
|
||||||
const updateDoc = {
|
|
||||||
$set: {[`resolutions.${postId}`]: resolution}
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = await db.getDb().collection('res').insertOne(resolution);
|
const result = await db.getDb().collection('res').insertOne(resolution);
|
||||||
return res.redirect('/hotLine')
|
return res.redirect('/hotLine')
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/accepter/:id', async function (req, res) {
|
router.post('/accepterPost/:id', async function (req, res) {
|
||||||
const postId = req.params.id;
|
const postId = req.params.id;
|
||||||
const winner = req.body.utilisateur;
|
const winner = req.body.utilisateur;
|
||||||
await db.getDb().collection('post').updateOne({_id: postId}, {isFinish: true});
|
|
||||||
await db.getDb().collection('res').updateOne({_id: postId}, {winner: winner});
|
|
||||||
res.redirect('/admin')
|
|
||||||
})
|
|
||||||
|
|
||||||
|
const ObjectID = mongodb.ObjectId;
|
||||||
|
const postObjectId = new ObjectID(postId);
|
||||||
|
|
||||||
|
await db.getDb().collection('posts').updateOne({ _id: postObjectId }, { $set: { isFinish: true, winner: winner } });
|
||||||
|
|
||||||
|
await db.getDb().collection('res').updateOne({ _id: postObjectId }, { $set: { winner: winner } });
|
||||||
|
|
||||||
|
return res.redirect('/admin');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
router.post('/supprimerPost/:id', async function (req, res) {
|
||||||
|
const postId = req.params.id;
|
||||||
|
const ObjectID = mongodb.ObjectId;
|
||||||
|
const postObjectId = new ObjectID(postId);
|
||||||
|
await db.getDb().collection('posts').deleteOne({ _id: postObjectId });
|
||||||
|
return res.redirect('/admin');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
|
@ -79,6 +79,14 @@
|
||||||
<p>
|
<p>
|
||||||
statue : Accepté
|
statue : Accepté
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
gagnant : <%= post.winner %>
|
||||||
|
</p>
|
||||||
|
<form action="/supprimerPost/<%= post._id %>" method="post">
|
||||||
|
<button>
|
||||||
|
Supprimer le poste
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<% } else {%>
|
<% } else {%>
|
||||||
<div id="postNotFinish">
|
<div id="postNotFinish">
|
||||||
|
@ -92,7 +100,7 @@
|
||||||
<p>
|
<p>
|
||||||
statue : en attente
|
statue : en attente
|
||||||
</p>
|
</p>
|
||||||
<form action="/accepter/<%= post._id %>" method="post">
|
<form action="/accepterPost/<%= post._id %>" method="post">
|
||||||
<div>
|
<div>
|
||||||
<label for="utilisateur">Le gagnant est : </label>
|
<label for="utilisateur">Le gagnant est : </label>
|
||||||
<select name="utilisateur" id="utilisateur">
|
<select name="utilisateur" id="utilisateur">
|
||||||
|
@ -105,6 +113,11 @@
|
||||||
Accepter
|
Accepter
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
<form action="/supprimerPost/<%= post._id %>" method="post">
|
||||||
|
<button>
|
||||||
|
Supprimer le poste
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% resData.forEach(res => {%>
|
<% resData.forEach(res => {%>
|
||||||
|
@ -119,7 +132,7 @@
|
||||||
<p>
|
<p>
|
||||||
<%= res.description %>
|
<%= res.description %>
|
||||||
</p>
|
</p>
|
||||||
<img src="<%= res.imagePath %>" alt="image de la resolution">
|
<img src="/<%= res.imagePath %>" alt="image de la resolution">
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
<ul>
|
<ul>
|
||||||
<% if (!locals.isAuth) { %>
|
<% if (!locals.isAuth) { %>
|
||||||
<li>
|
<li>
|
||||||
|
<a href="/connexion" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/connexion" class="custom-cursor">Se connecter</a>
|
Team
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (locals.isAuth) { %>
|
<% if (locals.isAuth) { %>
|
||||||
|
@ -19,12 +21,11 @@
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
<% } %>
|
||||||
<li>
|
<li>
|
||||||
<button class="btn" type="button">
|
<button class="btn custom-cursor" type="button" >
|
||||||
<strong>Explore</strong>
|
<strong>Explore</strong>
|
||||||
<div id="container-stars">
|
<div id="container-stars">
|
||||||
<div id="stars"></div>
|
<div id="stars"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="glow">
|
<div id="glow">
|
||||||
<div class="circle"></div>
|
<div class="circle"></div>
|
||||||
<div class="circle"></div>
|
<div class="circle"></div>
|
||||||
|
@ -36,46 +37,61 @@
|
||||||
<nav id="nav_id">
|
<nav id="nav_id">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
|
||||||
|
<a href="/team" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/team" class="custom-cursor">Team</a>
|
Team
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
<a href="/contact" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/contact" class="custom-cursor">Contact</a>
|
Contact
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
<a href="/sports" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/sports" class="custom-cursor">Les sports</a>
|
Les sports
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button href="/hotLine" class="button-85" role="button">
|
<a href="/evenement" class="custom-cursor">
|
||||||
<a href="/evenement" class="custom-cursor">Les événements</a>
|
<button class="button-85" role="button">
|
||||||
|
Les évenements
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
<a href="/A-propos" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/A-propos" class="custom-cursor">À propos</a>
|
À propos
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<% if (locals.isAuth) {%>
|
<% if (locals.isAuth) {%>
|
||||||
<li>
|
<li>
|
||||||
<form action="/profile" method="get">
|
<form action="/profile" method="get">
|
||||||
|
<a href="/profile" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/profile" class="custom-cursor">profile</a>
|
Profil
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (locals.isAdmin) { %>
|
<% if (locals.isAdmin) { %>
|
||||||
<li>
|
<li>
|
||||||
|
<a href="/admin" class="custom-cursor">
|
||||||
<button class="button-85" role="button">
|
<button class="button-85" role="button">
|
||||||
<a href="/admin" class="custom-cursor">Admin</a>
|
Admin
|
||||||
</button>
|
</button>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
<% } %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -9,8 +9,12 @@
|
||||||
</video>
|
</video>
|
||||||
|
|
||||||
<div class="divLogoPerm">
|
<div class="divLogoPerm">
|
||||||
|
<a href="https://www.instagram.com/bde_cs_metz/" class="custom-cursor">
|
||||||
<img src="img/logoPermantEpaule.JPG" alt="logo BDE permanent" id="logoPermBDE">
|
<img src="img/logoPermantEpaule.JPG" alt="logo BDE permanent" id="logoPermBDE">
|
||||||
|
</a>
|
||||||
|
<a href="https://www.instagram.com/metzpaslesdents/" class="custom-cursor">
|
||||||
<img id="logoliste" src="img/IMG_6768.JPG" alt="logo BDS" >
|
<img id="logoliste" src="img/IMG_6768.JPG" alt="logo BDS" >
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="container noselect" id="redirectButton">
|
<div class="container noselect" id="redirectButton">
|
||||||
<label for="checkbox" id="clickHandler"></label>
|
<label for="checkbox" id="clickHandler"></label>
|
||||||
|
@ -41,8 +45,10 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="divLogoPerm">
|
<div class="divLogoPerm custom-cursor">
|
||||||
|
<a href="https://www.instagram.com/metzpaslesdents/" class="custom-cursor">
|
||||||
<img src="img/logoMetzPloreur.JPG" alt="logo Metzploreur" id="logoMetzPloreur">
|
<img src="img/logoMetzPloreur.JPG" alt="logo Metzploreur" id="logoMetzPloreur">
|
||||||
|
</a>
|
||||||
</div >
|
</div >
|
||||||
</main>
|
</main>
|
||||||
<%- include('includes/footer') %>
|
<%- include('includes/footer') %>
|
||||||
|
|
Loading…
Reference in a new issue