hotLine work

This commit is contained in:
clement callaert 2023-11-02 20:15:23 +01:00
parent 6c77008d47
commit cc0a5ec15c
5 changed files with 87 additions and 42 deletions

View file

@ -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');

View file

@ -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;

View file

@ -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">
@ -101,10 +109,15 @@
<% }); %> <% }); %>
</select> </select>
</div> </div>
<button id="but<%= post._id %>"> <button id="but<%= post._id %>" >
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>
<% } %> <% } %>
<% }) %> <% }) %>

View file

@ -4,9 +4,11 @@
<ul> <ul>
<% if (!locals.isAuth) { %> <% if (!locals.isAuth) { %>
<li> <li>
<button class="button-85" role="button"> <a href="/connexion" class="custom-cursor">
<a href="/connexion" class="custom-cursor">Se connecter</a> <button class="button-85" role="button">
</button> Team
</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>
<button class="button-85" role="button">
<a href="/team" class="custom-cursor">Team</a> <a href="/team" class="custom-cursor">
</button> <button class="button-85" role="button">
Team
</button>
</a>
</li> </li>
<li> <li>
<button class="button-85" role="button"> <a href="/contact" class="custom-cursor">
<a href="/contact" class="custom-cursor">Contact</a> <button class="button-85" role="button">
</button> Contact
</button>
</a>
</li> </li>
<li> <li>
<button class="button-85" role="button"> <a href="/sports" class="custom-cursor">
<a href="/sports" class="custom-cursor">Les sports</a> <button class="button-85" role="button">
</button> Les sports
</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">
</button> Les évenements
</button>
</a>
</li> </li>
<li> <li>
<button class="button-85" role="button"> <a href="/A-propos" class="custom-cursor">
<a href="/A-propos" class="custom-cursor">À propos</a> <button class="button-85" role="button">
</button> À propos
</button>
</a>
</li> </li>
<% if (locals.isAuth) {%> <% if (locals.isAuth) {%>
<li> <li>
<form action="/profile" method="get"> <form action="/profile" method="get">
<button class="button-85" role="button"> <a href="/profile" class="custom-cursor">
<a href="/profile" class="custom-cursor">profile</a> <button class="button-85" role="button">
</button> Profil
</button>
</a>
</form> </form>
</li> </li>
<% } %> <% } %>
<% if (locals.isAdmin) { %> <% if (locals.isAdmin) { %>
<li> <li>
<button class="button-85" role="button"> <a href="/admin" class="custom-cursor">
<a href="/admin" class="custom-cursor">Admin</a> <button class="button-85" role="button">
</button> Admin
</button>
</a>
</li> </li>
<% } %> <% } %>
</ul> </ul>

View file

@ -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">
<img src="img/logoMetzPloreur.JPG" alt="logo Metzploreur" id="logoMetzPloreur"> <a href="https://www.instagram.com/metzpaslesdents/" class="custom-cursor">
<img src="img/logoMetzPloreur.JPG" alt="logo Metzploreur" id="logoMetzPloreur">
</a>
</div > </div >
</main> </main>
<%- include('includes/footer') %> <%- include('includes/footer') %>