add campaigns to homepage

This commit is contained in:
Yisroel Baum 2024-09-18 18:48:59 +03:00
parent 528d62010b
commit bdde079e43
2 changed files with 41 additions and 4 deletions

View file

@ -1,6 +1,7 @@
from app import db
from app.main import main
from app.users.models import User
from app.campaigns.models import Campaign
# from forms import LoginForm, RequestResetForm, ResetPasswordForm, EditUserForm, AddUserForm
from flask import render_template, redirect, url_for, flash, request
from flask_login import login_required, login_user, current_user, logout_user
@ -12,6 +13,7 @@ import os
@main.route('/homepage')
def homepage():
return render_template('homepage.html')
def homepage():
active_campaigns = Campaign.query.filter_by(active=True).all()
return render_template('homepage.html',
active_campaigns=active_campaigns)

View file

@ -1,2 +1,37 @@
{% extends 'base.html' %}
{% block title %}Customer Search{% endblock title %}
{% block title %}Homepage{% endblock title %}
{% block stylesheet %}
<style>
.custom-table {
border-radius: 15px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden; /* Ensures rounded corners apply to the entire table */
}
</style>
{% endblock stylesheet %}
{% block content %}
<main>
<div class="container my-4 px-5">
<h2 class="text-center">Visit Campaigns</h2>
<table class="table table-bordered table-striped custom-table">
<thead class="table-dark">
<tr>
<th>Title</th>
<th>Campaign Link</th>
</tr>
</thead>
<tbody>
{% for campaign in active_campaigns %}
<tr>
<td>{{campaign.title}}</td>
<td><a href="{{url_for('campaigns.campaign_page', campaign_id=campaign.id)}}">See campaign details</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</main>
{% endblock content %}