modified models to reflect specs - Course as a foreignkey and created event-detail.html + its views

parent 50544727
# Generated by Django 4.1.6 on 2023-05-15 13:53
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('announcements', '0002_alter_reaction_name'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_datetime',
field=models.DateTimeField(default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='reaction',
name='name',
field=models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], max_length=10),
),
]
# Generated by Django 4.1.6 on 2023-05-15 13:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0002_alter_event_target_datetime'),
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('course_code', models.CharField(max_length=10)),
('section', models.CharField(max_length=5)),
],
),
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_calendar.course'),
),
]
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block content %}
<h2>Widget's Calendar of Activities</h2>
{% for event in events %}
<a href="{{ event.get_absolute_url }}">{{event.activity}}</a><br>
{% endfor %}
<br>
<a href="{% url 'widget_calendar:event-add' %}" class="button"> New Activity </a><br>
<a href="{% url 'dashboard:pageview' %}">Dashboard</a><br>
<a href="{% url 'announcements:pageview' %}">Announcements</a><br>
<a href="{% url 'forum:pageview' %}">Forum</a><br>
<a href="{% url 'assignments:pageview' %}">Assignments</a><br>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import pageview from .views import pageview, Widget_CalendarDetailView, Widget_CalendarCreateView, Widget_CalendarEventUpdateView
urlpatterns = [ urlpatterns = [
path('', pageview, name='pageview'), path('', pageview, name='pageview'),
path('widget_calender/events/<int:pk>/details', Widget_CalenderDetailView.as_view(), name='event-details'), path('widget_calender/events/<int:pk>/details', Widget_CalendarDetailView.as_view(), name='event-details'),
path('widget_calender/add', Widget_CalendarCreateView.as_view(), name='event-add'), path('widget_calender/add', Widget_CalendarCreateView.as_view(), name='event-add'),
path('widget_calender/events/<int:pk>/edit', Widget_CalendarEventUpdateView.as_view(), name='event-edit'), path('widget_calender/events/<int:pk>/edit', Widget_CalendarEventUpdateView.as_view(), name='event-edit'),
] ]
......
...@@ -14,4 +14,21 @@ class Widget_CalendarDetailView(DetailView): ...@@ -14,4 +14,21 @@ class Widget_CalendarDetailView(DetailView):
event = Event.objects.get(pk=pk) event = Event.objects.get(pk=pk)
course = event.course course = event.course
venue = event.location venue = event.location
return render(request, 'dashboard/widgetuser-details.html', {'department': department, 'user': user})
return render(request, 'widget_calendar/event-details.html', {'event': event, 'course': course, 'venue': venue})
class Widget_CalendarCreateView(CreateView):
def get(self, request, pk):
event = Event.objects.get(pk=pk)
course = event.course
venue = event.location
return render(request, 'widget_calendar/event-details.html', {'event': event, 'course': course, 'venue': venue})
class Widget_CalendarEventUpdateView(UpdateView):
def get(self, request, pk):
event = Event.objects.get(pk=pk)
course = event.course
venue = event.location
return render(request, 'widget_calendar/event-details.html', {'event': event, 'course': course, 'venue': venue})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment