Commit f08eca11 authored by nheoxoz's avatar nheoxoz

Merge branch 'origin/dashboardv2'

parents b357a962 04831701
from django.db import models
from django.urls import reverse
class Department(models.Model):
......@@ -21,3 +22,6 @@ class WidgetUser(models.Model):
self.first_name,
self.middle_name
)
def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs={'pk': self.pk})
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget v2{% endblock %}
{% block heading %}Welcome to Widget!{% endblock %}
{% block content %}
<p>
WIDGET USERS:<br>
{% for user in users %}
<a href="{{ user.get_absolute_url }}">
{{ user.last_name }}, {{ user.first_name }}
</a><br>
{% endfor %}
</p>
{% endblock %}
{% block footing %}
<a href="{% url 'dashboard:widgetuser-create' %}">
<button class="btn add">Add Widget User</button>
</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block heading %}<h1>Add a new Widget User:</h1>{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Add Widget User">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.last_name }}, {{ object.first_name }}{% endblock %}
{% block heading %}
<h1>
{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}
</h1>
{% endblock %}
{% block content %}
<p>
{{ object.department.dept_name }}<br>
{{ object.department.home_unit }}<br>
</p>
{% endblock %}
{% block footing %}
<a href="{% url 'dashboard:widgetuser-update' object.pk %}">
<button class="btn edit">Edit Widget User</button>
</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Widget User{% endblock %}
{% block heading %}Edit Widget User:{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Widget User">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import (dashboard, WidgetUserDetailView,
WidgetUserCreateView, WidgetUserUpdateView)
urlpatterns = [
path('', index, name='index'),
path('dashboard/',
dashboard,
name='dashboard'),
path('widgetusers/<int:pk>/details/',
WidgetUserDetailView.as_view(),
name='widgetuser-details'),
path('widgetusers/add/',
WidgetUserCreateView.as_view(),
name='widgetuser-create'),
path('widgetusers/<int:pk>/edit/',
WidgetUserUpdateView.as_view(),
name='widgetuser-update'),
]
app_name = "dashboard"
from django.shortcuts import HttpResponse
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import WidgetUser
def index(request):
return_string = '<p>Welcome to Widget!</p>WIDGET USERS:<br>'
for user in WidgetUser.objects.all():
return_string += '{}: {}<br>'.format(user, user.department)
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(html_string)
def dashboard(request):
users = WidgetUser.objects.all()
return render(request, 'dashboard/dashboard.html', {'users': users})
class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name = 'dashboard/widgetuser-details.html'
class WidgetUserCreateView(CreateView):
model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-add.html'
class WidgetUserUpdateView(UpdateView):
model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-edit.html'
......@@ -17,7 +17,7 @@ from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('', include('dashboard.urls', namespace="dashboard")),
path('forum/', include('forum.urls', namespace="forum")),
path('announcements/', include('announcements.urls', namespace="announcements")),
path('widget_calendar/', include('widget_calendar.urls', namespace="calendar")),
......
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