mirror of
https://github.com/rudy3333/eversync.git
synced 2025-05-10 02:03:06 +00:00
calendar very early wip
This commit is contained in:
parent
1e9698ca3e
commit
b6e4e7ab3a
5 changed files with 140 additions and 4 deletions
85
calendar.html
Normal file
85
calendar.html
Normal file
|
@ -0,0 +1,85 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Eversync</title>
|
||||
{% load static %}
|
||||
<link rel="icon" href="{% static 'favicon.ico' %}">
|
||||
<link rel="stylesheet" href="{% static 'index-style.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'register-style.css' %}">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
||||
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@6.1.17/index.global.min.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<div class="header-content">
|
||||
<a href="/"><img src="{% static 'eversync2.png' %}" alt="Eversync Logo" style="height: 80px; margin-right: 10px; display: flex; align-items: center; gap: 5px;"></a>
|
||||
<a href="/" class="logo" >eversync</a>
|
||||
<div class="nav-links" style="position: relative;">
|
||||
<div class="dropdown">
|
||||
<button class="dropdown-toggle" style="background: none; border: none; color: white; font-size: 16px; cursor: pointer;">
|
||||
Welcome, {{ user.username }} <i class="fas fa-caret-down"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" style="display: none; position: absolute; right: 0; background-color: #333; border: 1px solid #444; border-radius: 4px; padding: 10px; width: 184px;">
|
||||
|
||||
<form action="{% url 'manage' %}" method="post" style="margin: 0;">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Manage Account</button>
|
||||
</form>
|
||||
|
||||
<form action="{% url 'logoutz' %}" method="post" style="margin: 0;">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Log Out</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>Calendar</h1>
|
||||
<div class="calendar-container">
|
||||
<div id="calendar"></div>
|
||||
</div>
|
||||
<style>
|
||||
.calendar-container {
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const calendarEl = document.getElementById('calendar');
|
||||
const calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
headerToolbar: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'dayGridMonth,timeGridWeek,timeGridDay'
|
||||
},
|
||||
initialView: 'dayGridMonth',
|
||||
events: '/calendar/events/', //FIX
|
||||
editable: true,
|
||||
droppable: true,
|
||||
});
|
||||
calendar.render();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const toggle = document.querySelector('.dropdown-toggle');
|
||||
const menu = document.querySelector('.dropdown-menu');
|
||||
toggle.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
menu.style.display = menu.style.display === 'block' ? 'none' : 'block';
|
||||
});
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!toggle.contains(e.target) && !menu.contains(e.target)) {
|
||||
menu.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
27
eversyncc/migrations/0004_event.py
Normal file
27
eversyncc/migrations/0004_event.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 5.2 on 2025-05-08 22:42
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('eversyncc', '0003_alter_document_file'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Event',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('start_time', models.DateTimeField()),
|
||||
('end_time', models.DateTimeField()),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -10,3 +10,13 @@ class Document(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Event(models.Model):
|
||||
title = models.CharField(max_length=200)
|
||||
description = models.TextField(blank=True)
|
||||
start_time = models.DateTimeField()
|
||||
end_time = models.DateTimeField()
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.urls import path
|
||||
from . import views
|
||||
from .views import RedirectFromLogin, upload_file, file_list, delete_file
|
||||
from .views import RedirectFromLogin, upload_file, file_list, delete_file, calendar
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
|
@ -16,7 +16,8 @@ urlpatterns = [
|
|||
path("accounts/login/", RedirectFromLogin.as_view(), name="login"),
|
||||
path('upload/', upload_file, name='upload_file'),
|
||||
path('file_list/', file_list, name='file_list'),
|
||||
path('delete_file/<int:file_id>', delete_file, name='delete_file')
|
||||
path('delete_file/<int:file_id>', delete_file, name='delete_file'),
|
||||
path('calendar/', calendar, name="calendar")
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.contrib.auth import logout
|
|||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.views import PasswordChangeView
|
||||
from .forms import UsernameChangeForm, DocumentForm
|
||||
from .models import Document
|
||||
from .models import Document, Event
|
||||
from django.contrib import messages
|
||||
from allauth.account.views import LoginView as AllauthLoginView
|
||||
import os
|
||||
|
@ -122,3 +122,16 @@ def delete_file(request, file_id):
|
|||
return JsonResponse({'message' : 'Success.'})
|
||||
except Document.DoesNotExist:
|
||||
return JsonResponse({'error': 'Error.'}, status=404)
|
||||
|
||||
@login_required
|
||||
def calendar(request):
|
||||
events = Event.objects.filter(user=request.user)
|
||||
events_data = [
|
||||
{
|
||||
"title": event.title,
|
||||
"start": event.start_time.isoformat(),
|
||||
"end": event.end_time.isoformat(),
|
||||
}
|
||||
for event in events
|
||||
]
|
||||
return render(request, 'calendar.html', {'events_data': events_data})
|
Loading…
Add table
Add a link
Reference in a new issue