Commit 7565a8bd authored by MJoshBen's avatar MJoshBen

Implemented Edit Announcement and adjusted the Models. Views and URLs accordingly

parent 273425e9
from django.db import models from django.db import models
from dashboard.models import WidgetUser
from django.urls import reverse from django.urls import reverse
# Create your models here. # Create your models here.
......
{% extends 'base.html' %}
{% block title %}Edit Announcement{% endblock %}
<h1>Edit Announcement:</h1>
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Announcement">
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path
from .views import index, AnnouncementDetailView, AnnouncementCreateView from .views import index, AnnouncementDetailView, AnnouncementCreateView, AnnouncementUpdateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
path('<int:pk>/details', AnnouncementDetailView.as_view(), name='announcement-details'), path('<int:pk>/details', AnnouncementDetailView.as_view(), name='announcement-details'),
path('add/', AnnouncementCreateView.as_view(), name='add-announcement') path('add/', AnnouncementCreateView.as_view(), name='add-announcement'),
path('<int:pk>/edit', AnnouncementUpdateView.as_view(), name = "edit-announcement")
] ]
app_name = "announcement" app_name = "announcement"
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement from .models import Announcement
...@@ -18,3 +18,8 @@ class AnnouncementCreateView(CreateView): ...@@ -18,3 +18,8 @@ class AnnouncementCreateView(CreateView):
fields = '__all__' fields = '__all__'
template_name = 'announcement/announcement-add.html' template_name = 'announcement/announcement-add.html'
class AnnouncementUpdateView(UpdateView):
model = Announcement
fields = '__all__'
template_name = 'announcement/announcement-edit.html'
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