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(authRoutes);
app.use(postsRoutes);
app.use('/images', express.static(path.join(__dirname, 'images')));
app.use(function(error, req, res, next) {
res.render('500');

View file

@ -82,24 +82,32 @@ router.post('/submitResolution/:postId', upload.single('image'), async function
prenom: prenom,
imagePath: path
}
const filter = {id: postId};
const updateDoc = {
$set: {[`resolutions.${postId}`]: resolution}
};
const result = await db.getDb().collection('res').insertOne(resolution);
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 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;

View file

@ -79,6 +79,14 @@
<p>
statue : Accepté
</p>
<p>
gagnant : <%= post.winner %>
</p>
<form action="/supprimerPost/<%= post._id %>" method="post">
<button>
Supprimer le poste
</button>
</form>
</div>
<% } else {%>
<div id="postNotFinish">
@ -92,7 +100,7 @@
<p>
statue : en attente
</p>
<form action="/accepter/<%= post._id %>" method="post">
<form action="/accepterPost/<%= post._id %>" method="post">
<div>
<label for="utilisateur">Le gagnant est : </label>
<select name="utilisateur" id="utilisateur">
@ -101,10 +109,15 @@
<% }); %>
</select>
</div>
<button id="but<%= post._id %>">
<button id="but<%= post._id %>" >
Accepter
</button>
</form>
<form action="/supprimerPost/<%= post._id %>" method="post">
<button>
Supprimer le poste
</button>
</form>
</div>
<% } %>
<% resData.forEach(res => {%>
@ -119,7 +132,7 @@
<p>
<%= res.description %>
</p>
<img src="<%= res.imagePath %>" alt="image de la resolution">
<img src="/<%= res.imagePath %>" alt="image de la resolution">
</div>
<% } %>
<% }) %>

View file

@ -4,9 +4,11 @@
<ul>
<% if (!locals.isAuth) { %>
<li>
<button class="button-85" role="button">
<a href="/connexion" class="custom-cursor">Se connecter</a>
</button>
<a href="/connexion" class="custom-cursor">
<button class="button-85" role="button">
Team
</button>
</a>
</li>
<% } %>
<% if (locals.isAuth) { %>
@ -19,12 +21,11 @@
</li>
<% } %>
<li>
<button class="btn" type="button">
<button class="btn custom-cursor" type="button" >
<strong>Explore</strong>
<div id="container-stars">
<div id="stars"></div>
</div>
<div id="glow">
<div class="circle"></div>
<div class="circle"></div>
@ -36,46 +37,61 @@
<nav id="nav_id">
<ul>
<li>
<button class="button-85" role="button">
<a href="/team" class="custom-cursor">Team</a>
</button>
<a href="/team" class="custom-cursor">
<button class="button-85" role="button">
Team
</button>
</a>
</li>
<li>
<button class="button-85" role="button">
<a href="/contact" class="custom-cursor">Contact</a>
</button>
<a href="/contact" class="custom-cursor">
<button class="button-85" role="button">
Contact
</button>
</a>
</li>
<li>
<button class="button-85" role="button">
<a href="/sports" class="custom-cursor">Les sports</a>
</button>
<a href="/sports" class="custom-cursor">
<button class="button-85" role="button">
Les sports
</button>
</a>
</li>
<li>
<button href="/hotLine" class="button-85" role="button">
<a href="/evenement" class="custom-cursor">Les événements</a>
</button>
<a href="/evenement" class="custom-cursor">
<button class="button-85" role="button">
Les évenements
</button>
</a>
</li>
<li>
<button class="button-85" role="button">
<a href="/A-propos" class="custom-cursor">À propos</a>
</button>
<a href="/A-propos" class="custom-cursor">
<button class="button-85" role="button">
À propos
</button>
</a>
</li>
<% if (locals.isAuth) {%>
<li>
<form action="/profile" method="get">
<button class="button-85" role="button">
<a href="/profile" class="custom-cursor">profile</a>
</button>
<a href="/profile" class="custom-cursor">
<button class="button-85" role="button">
Profil
</button>
</a>
</form>
</li>
<% } %>
<% if (locals.isAdmin) { %>
<li>
<button class="button-85" role="button">
<a href="/admin" class="custom-cursor">Admin</a>
</button>
<a href="/admin" class="custom-cursor">
<button class="button-85" role="button">
Admin
</button>
</a>
</li>
<% } %>
</ul>

View file

@ -9,8 +9,12 @@
</video>
<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">
</a>
<a href="https://www.instagram.com/metzpaslesdents/" class="custom-cursor">
<img id="logoliste" src="img/IMG_6768.JPG" alt="logo BDS" >
</a>
</div>
<div class="container noselect" id="redirectButton">
<label for="checkbox" id="clickHandler"></label>
@ -41,8 +45,10 @@
});
</script>
<div class="divLogoPerm">
<img src="img/logoMetzPloreur.JPG" alt="logo Metzploreur" id="logoMetzPloreur">
<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">
</a>
</div >
</main>
<%- include('includes/footer') %>