nec / index.html
visman1990's picture
modèle, vue et urls pour ce template - Initial Deployment
5c24431 verified
Raw History Blame Contribute Delete
28.4 kB
# urls.py
from django.urls import path
from .views import dashboard_view
urlpatterns = [
path('dashboard/', dashboard_view, name='political_dashboard'),
]
# views.py
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from .models import PartyMember, PollData, Event, NewsItem
from django.utils import timezone
@login_required
def dashboard_view(request):
# Get stats data
total_members = PartyMember.objects.filter(is_active=True).count()
# Get latest poll data
latest_poll = PollData.objects.order_by('-date').first()
# Get upcoming events
upcoming_events = Event.objects.filter(date__gte=timezone.now()).order_by('date')[:3]
# Get latest news
latest_news = NewsItem.objects.order_by('-date')[:3]
# Regional distribution (example data)
regional_distribution = {
'Nord': 32,
'Sud': 24,
'Est': 18,
'Ouest': 26
}
context = {
'total_members': total_members,
'poll_data': latest_poll,
'upcoming_events': upcoming_events,
'latest_news': latest_news,
'regional_distribution': regional_distribution,
'user': request.user
}
return render(request, 'dashboard/political_dashboard.html', context)
# models.py
from django.db import models
from django.contrib.auth.models import User
class PartyMember(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
position = models.CharField(max_length=100)
region = models.CharField(max_length=50)
join_date = models.DateField(auto_now_add=True)
is_active = models.BooleanField(default=True)
def __str__(self):
return f"{self.user.get_full_name()} - {self.position}"
class PollData(models.Model):
date = models.DateField()
our_party = models.FloatField()
main_opponent = models.FloatField()
other_parties = models.JSONField(default=dict)
class Meta:
ordering = ['-date']
def __str__(self):
return f"Poll data for {self.date}"
class Event(models.Model):
title = models.CharField(max_length=200)
date = models.DateTimeField()
location = models.CharField(max_length=200)
description = models.TextField()
event_type = models.CharField(max_length=50, choices=[
('meeting', 'Meeting'),
('debate', 'Debate'),
('fundraiser', 'Fundraiser'),
('other', 'Other')
])
attendees = models.ManyToManyField(PartyMember, blank=True)
def __str__(self):
return self.title
class NewsItem(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
date = models.DateTimeField(auto_now_add=True)
image = models.ImageField(upload_to='news_images/')
views = models.PositiveIntegerField(default=0)
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
def __str__(self):
return self.title
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tableau de Bord - Parti Politique</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.chart-container {
position: relative;
height: 250px;
width: 100%;
}
.progress-ring__circle {
transition: stroke-dashoffset 0.5s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
.news-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<div class="hidden md:flex md:flex-shrink-0">
<div class="flex flex-col w-64 bg-blue-900 text-white">
<div class="flex items-center justify-center h-16 px-4 bg-blue-800">
<div class="flex items-center">
<i class="fas fa-landmark text-2xl mr-2 text-blue-300"></i>
<span class="text-xl font-bold">POLITICO</span>
</div>
</div>
<div class="flex flex-col flex-grow px-4 py-4 overflow-y-auto">
<div class="space-y-1">
<a href="#" class="flex items-center px-2 py-3 text-sm font-medium rounded-md bg-blue-800 text-white">
<i class="fas fa-tachometer-alt mr-3 text-blue-300"></i>
Tableau de bord
</a>
<a href="#" class="flex items-center px-2 py-3 text-sm font-medium rounded-md text-blue-200 hover:bg-blue-800 hover:text-white">
<i class="fas fa-users mr-3"></i>
Membres
</a>
<a href="#" class="flex items-center px-2 py-3 text-sm font-medium rounded-md text-blue-200 hover:bg-blue-800 hover:text-white">
<i class="fas fa-poll mr-3"></i>
Sondages
</a>
<a href="#" class="flex items-center px-2 py-3 text-sm font-medium rounded-md text-blue-200 hover:bg-blue-800 hover:text-white">
<i class="fas fa-calendar-alt mr-3"></i>
Événements
</a>
<a href="#" class="flex items-center px-2 py-3 text-sm font-medium rounded-md text-blue-200 hover:bg-blue-800 hover:text-white">
<i class="fas fa-newspaper mr-3"></i>
Actualités
</a>
<a href="#" class="flex items-center px-2 py-3 text-sm font-medium rounded-md text-blue-200 hover:bg-blue-800 hover:text-white">
<i class="fas fa-money-bill-wave mr-3"></i>
Financement
</a>
</div>
<div class="mt-auto mb-4">
<div class="px-2 py-3 bg-blue-800 rounded-md">
<div class="flex items-center">
<div class="flex-shrink-0">
<img class="h-10 w-10 rounded-full" src="https://randomuser.me/api/portraits/men/32.jpg" alt="">
</div>
<div class="ml-3">
<p class="text-sm font-medium text-white">Jean Dupont</p>
<p class="text-xs font-medium text-blue-300">Président</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Main content -->
<div class="flex flex-col flex-1 overflow-hidden">
<!-- Top navigation -->
<div class="flex items-center justify-between h-16 px-4 bg-white border-b border-gray-200">
<div class="flex items-center md:hidden">
<button class="text-gray-500 focus:outline-none">
<i class="fas fa-bars"></i>
</button>
</div>
<div class="flex-1 px-4">
<div class="relative max-w-md">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i class="fas fa-search text-gray-400"></i>
</div>
<input class="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-md leading-5 bg-white placeholder-gray-500 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" placeholder="Rechercher..." type="search">
</div>
</div>
<div class="flex items-center">
<button class="p-1 text-gray-400 rounded-full hover:text-gray-500 focus:outline-none">
<i class="fas fa-bell"></i>
</button>
<div class="ml-3 relative">
<div>
<button class="flex items-center max-w-xs text-sm rounded-full focus:outline-none">
<img class="h-8 w-8 rounded-full" src="https://randomuser.me/api/portraits/men/32.jpg" alt="">
</button>
</div>
</div>
</div>
</div>
<!-- Main content area -->
<div class="flex-1 overflow-auto p-4 bg-gray-50">
<div class="mb-6">
<h1 class="text-2xl font-bold text-gray-800">Tableau de Bord</h1>
<p class="text-gray-600">Bienvenue dans l'espace d'administration du parti</p>
</div>
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6">
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-3 rounded-full bg-blue-100 text-blue-600">
<i class="fas fa-users text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Membres</p>
<p class="text-2xl font-semibold text-gray-800">1,248</p>
<p class="text-sm text-green-500 flex items-center">
<i class="fas fa-arrow-up mr-1"></i> 12% depuis le mois dernier
</p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-3 rounded-full bg-green-100 text-green-600">
<i class="fas fa-poll text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Intentions de vote</p>
<p class="text-2xl font-semibold text-gray-800">24.5%</p>
<p class="text-sm text-red-500 flex items-center">
<i class="fas fa-arrow-down mr-1"></i> 2.3% depuis la semaine dernière
</p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-3 rounded-full bg-purple-100 text-purple-600">
<i class="fas fa-calendar-alt text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Événements à venir</p>
<p class="text-2xl font-semibold text-gray-800">7</p>
<p class="text-sm text-green-500 flex items-center">
<i class="fas fa-circle-notch mr-1 animate-spin"></i> 3 nouveaux cette semaine
</p>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center">
<div class="p-3 rounded-full bg-yellow-100 text-yellow-600">
<i class="fas fa-money-bill-wave text-xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Financement</p>
<p class="text-2xl font-semibold text-gray-800">€245,670</p>
<p class="text-sm text-green-500 flex items-center">
<i class="fas fa-arrow-up mr-1"></i> €12,450 ce mois-ci
</p>
</div>
</div>
</div>
</div>
<!-- Main Charts -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
<!-- Sondages -->
<div class="lg:col-span-2 bg-white rounded-lg shadow p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-semibold text-gray-800">Évolution des intentions de vote</h2>
<div class="flex space-x-2">
<button class="px-3 py-1 text-xs bg-blue-100 text-blue-600 rounded-full">Mois</button>
<button class="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded-full">Trimestre</button>
<button class="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded-full">Année</button>
</div>
</div>
<div class="chart-container">
<canvas id="pollChart"></canvas>
</div>
</div>
<!-- Répartition géographique -->
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4">Répartition géographique</h2>
<div class="chart-container">
<canvas id="regionChart"></canvas>
</div>
<div class="mt-4 grid grid-cols-2 gap-2">
<div class="flex items-center">
<div class="w-3 h-3 rounded-full bg-blue-500 mr-2"></div>
<span class="text-xs text-gray-600">Nord (32%)</span>
</div>
<div class="flex items-center">
<div class="w-3 h-3 rounded-full bg-green-500 mr-2"></div>
<span class="text-xs text-gray-600">Sud (24%)</span>
</div>
<div class="flex items-center">
<div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
<span class="text-xs text-gray-600">Est (18%)</span>
</div>
<div class="flex items-center">
<div class="w-3 h-3 rounded-full bg-purple-500 mr-2"></div>
<span class="text-xs text-gray-600">Ouest (26%)</span>
</div>
</div>
</div>
</div>
<!-- Bottom Section -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Dernières actualités -->
<div class="lg:col-span-2 bg-white rounded-lg shadow p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4">Dernières actualités</h2>
<div class="space-y-4">
<div class="news-card transition duration-300 ease-in-out bg-gray-50 rounded-lg p-4 border border-gray-200">
<div class="flex items-start">
<img src="https://source.unsplash.com/random/80x80/?politics" alt="News" class="w-16 h-16 rounded-md object-cover">
<div class="ml-4">
<h3 class="font-medium text-gray-800">Nouvelle réforme économique annoncée</h3>
<p class="text-sm text-gray-600 mt-1">Le président a dévoilé aujourd'hui une série de mesures pour stimuler l'économie...</p>
<div class="flex items-center mt-2 text-xs text-gray-500">
<span><i class="fas fa-clock mr-1"></i> Il y a 2 heures</span>
<span class="ml-3"><i class="fas fa-eye mr-1"></i> 1.2K vues</span>
</div>
</div>
</div>
</div>
<div class="news-card transition duration-300 ease-in-out bg-gray-50 rounded-lg p-4 border border-gray-200">
<div class="flex items-start">
<img src="https://source.unsplash.com/random/80x80/?meeting" alt="News" class="w-16 h-16 rounded-md object-cover">
<div class="ml-4">
<h3 class="font-medium text-gray-800">Réunion stratégique avec les cadres régionaux</h3>
<p class="text-sm text-gray-600 mt-1">Les responsables régionaux se sont réunis pour discuter de la stratégie électorale...</p>
<div class="flex items-center mt-2 text-xs text-gray-500">
<span><i class="fas fa-clock mr-1"></i> Il y a 5 heures</span>
<span class="ml-3"><i class="fas fa-eye mr-1"></i> 845 vues</span>
</div>
</div>
</div>
</div>
<div class="news-card transition duration-300 ease-in-out bg-gray-50 rounded-lg p-4 border border-gray-200">
<div class="flex items-start">
<img src="https://source.unsplash.com/random/80x80/?campaign" alt="News" class="w-16 h-16 rounded-md object-cover">
<div class="ml-4">
<h3 class="font-medium text-gray-800">Lancement de la campagne jeunesse</h3>
<p class="text-sm text-gray-600 mt-1">Notre nouvelle campagne pour engager les jeunes électeurs commence la semaine prochaine...</p>
<div class="flex items-center mt-2 text-xs text-gray-500">
<span><i class="fas fa-clock mr-1"></i> Hier</span>
<span class="ml-3"><i class="fas fa-eye mr-1"></i> 2.1K vues</span>
</div>
</div>
</div>
</div>
</div>
<button class="mt-4 w-full py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md text-sm font-medium transition duration-150">
Voir toutes les actualités
</button>
</div>
<!-- Prochains événements -->
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4">Prochains événements</h2>
<div class="space-y-4">
<div class="flex items-start">
<div class="flex-shrink-0 bg-blue-100 text-blue-600 rounded-lg p-3">
<div class="text-center">
<div class="text-xs font-semibold">JUIN</div>
<div class="text-xl font-bold">15</div>
</div>
</div>
<div class="ml-4">
<h3 class="font-medium text-gray-800">Congrès national</h3>
<p class="text-sm text-gray-600 mt-1">10:00 - 18:00 • Centre des Congrès</p>
<div class="mt-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
<i class="fas fa-users mr-1"></i> 250 participants
</span>
</div>
</div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 bg-green-100 text-green-600 rounded-lg p-3">
<div class="text-center">
<div class="text-xs font-semibold">JUIN</div>
<div class="text-xl font-bold">22</div>
</div>
</div>
<div class="ml-4">
<h3 class="font-medium text-gray-800">Débat télévisé</h3>
<p class="text-sm text-gray-600 mt-1">20:30 - 22:30 • Chaîne Nationale</p>
<div class="mt-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
<i class="fas fa-tv mr-1"></i> Diffusion en direct
</span>
</div>
</div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 bg-purple-100 text-purple-600 rounded-lg p-3">
<div class="text-center">
<div class="text-xs font-semibold">JUIN</div>
<div class="text-xl font-bold">28</div>
</div>
</div>
<div class="ml-4">
<h3 class="font-medium text-gray-800">Collecte de fonds</h3>
<p class="text-sm text-gray-600 mt-1">19:00 - 23:00 • Hôtel Majestic</p>
<div class="mt-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800">
<i class="fas fa-star mr-1"></i> VIP
</span>
</div>
</div>
</div>
</div>
<button class="mt-4 w-full py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition duration-150">
<i class="fas fa-plus mr-2"></i> Ajouter un événement
</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Poll Chart
const pollCtx = document.getElementById('pollChart').getContext('2d');
const pollChart = new Chart(pollCtx, {
type: 'line',
data: {
labels: ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin'],
datasets: [
{
label: 'Notre parti',
data: [22, 23, 25, 26, 24.5, 24.5],
borderColor: '#3B82F6',
backgroundColor: 'rgba(59, 130, 246, 0.1)',
borderWidth: 2,
tension: 0.3,
fill: true
},
{
label: 'Principal adversaire',
data: [28, 27, 26, 25, 26, 25.5],
borderColor: '#EF4444',
backgroundColor: 'rgba(239, 68, 68, 0.1)',
borderWidth: 2,
tension: 0.3,
fill: true
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top',
},
tooltip: {
mode: 'index',
intersect: false,
}
},
scales: {
y: {
beginAtZero: false,
min: 15,
max: 35,
ticks: {
callback: function(value) {
return value + '%';
}
}
}
}
}
});
// Region Chart
const regionCtx = document.getElementById('regionChart').getContext('2d');
const regionChart = new Chart(regionCtx, {
type: 'doughnut',
data: {
labels: ['Nord', 'Sud', 'Est', 'Ouest'],
datasets: [{
data: [32, 24, 18, 26],
backgroundColor: [
'#3B82F6',
'#10B981',
'#F59E0B',
'#8B5CF6'
],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
}
},
cutout: '70%'
}
});
// Mobile menu toggle
document.querySelector('.md\\:hidden button').addEventListener('click', function() {
document.querySelector('.hidden.md\\:flex').classList.toggle('hidden');
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=visman1990/nec" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>