Commit 163e8db8 authored by Nics De Vega's avatar Nics De Vega

fixed merge conflicts in dashboardv2

parents cd772cb6 e3f09419
from django.db import models from django.db import models
from django.urls import reverse
class Department(models.Model): class Department(models.Model):
dept_name = models.CharField(max_length=100,unique=True,default="") dept_name = models.CharField(max_length=100,unique=True,default="")
...@@ -14,4 +15,8 @@ class WidgetUser(models.Model): ...@@ -14,4 +15,8 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department,on_delete=models.CASCADE) department = models.ForeignKey(Department,on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return '{} {}'.format(self.first_name, self.last_name) return '{}, {}'.format(self.last_name, self.first_name)
\ No newline at end of file
def get_absolute_url(self):
return reverse('dashboard:user_details', kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget v2{% endblock %}
{% block content %}
<i><h1>Welcome to Widget!</h1></i>
<h3>Widget Users:</h3>
{% for user in user %}
<p><strong>
<a href="{{ user.get_absolute_url }}">
<li>
{{ user.last_name }}, {{ user.first_name }}
</li>
</a>
</strong></p>
{% endfor %}
<br><br>
<a href="./widgetusers/add/">
<button type="button"><p>Add Widget User</p></button>
</a>
<br><br><br>
{# the links to other html files #}
<div class = links>
<a href="../announcements/">Announcement Board</a><br>
<a href="../forum/">Forum</a><br>
<a href="../assignments/">Assignments</a><br>
<a href="../calendar/">Calendar</a><br>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block content %}
<h1>Add a new Widget user:</h1>
<div class="new_user">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Add Widget User</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.last_name }}, {{ object.first_name }} {% endblock %}
{% block content %}
<div style="text-transform:uppercase;">
<h1>{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}</h1>
</div>
<h2>
{{ object.department.dept_name }} <br>
{{ object.department.home_unit }} <br>
</h2>
<a href="../edit/">
<button type="button"><p>Edit Widget User</p></button>
</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Widget User{% endblock %}
{% block content %}
<h1>Edit Widget User:</h1>
<div class="update_user">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Widget User">
</form>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import *
urlpatterns = [ urlpatterns = [
path('',index,name='index') path('',index,name='index'),
path('dashboard/',WidgetUserListView,name='user_list'),
path('widgetusers/<int:pk>/details/',WidgetUserDetailView.as_view(),name='user_details'),
path('widgetusers/add/',WidgetUserCreateView.as_view(),name='new_user'),
path('widgetusers/<int:pk>/edit/',WidgetUserUpdateView.as_view(),name='edit_user'),
] ]
app_name = 'announcement_board' app_name = 'announcement_board'
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse
from .models import WidgetUser from .models import WidgetUser
from django.views.generic.edit import CreateView, UpdateView
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
def index(request): def index(request):
return_string = '<body>' user = WidgetUser.objects.all()
for user in WidgetUser.objects.all(): args = {'user':user}
user_string = '{}, {} {}'.format( return render(request, 'dashboard/dashboard.html', args)
user.last_name, user.first_name, user.middle_name
) class WidgetUserListView(ListView):
dept_string = '{}: {}'.format( template_name='dashboard/dashboard.html'
user.department.dept_name, user.department.home_unit
) class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name='dashboard/widgetuser-details.html'
class WidgetUserCreateView(CreateView):
model = WidgetUser
template_name = 'dashboard/widgetuser-add.html'
fields = '__all__'
class WidgetUserUpdateView(UpdateView):
model = WidgetUser
template_name = 'dashboard/widgetuser-edit.html'
fields = '__all__'
# from django.shortcuts import render
# from django.http import HttpResponse
# from .models import WidgetUser
# def index(request):
# return_string = '<body>'
# for user in WidgetUser.objects.all():
# user_string = '{}, {} {}'.format(
# user.last_name, user.first_name, user.middle_name
# )
# dept_string = '{}: {}'.format(
# user.department.dept_name, user.department.home_unit
# )
return_string += user_string + " from the " + dept_string + "<br>" # return_string += user_string + " from the " + dept_string + "<br>"
html_string = '<html>{}</html>'.format(return_string) # html_string = '<html>{}</html>'.format(return_string)
return HttpResponse("Welcome to Widget! <br> <br>WIDGET USERS: <br>" + html_string) # return HttpResponse("Welcome to Widget! <br> <br>WIDGET USERS: <br>" + html_string)
\ No newline at end of file \ No newline at end of file
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
<html lang="en"> <html lang="en">
{% load static %} {% load static %}
<head> <head>
<<<<<<< HEAD
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
=======
>>>>>>> dashboardv2
<link rel="stylesheet" href=" {% static '/css/style.css' %}"> <link rel="stylesheet" href=" {% static '/css/style.css' %}">
</head> </head>
<body style ="background-color: #afcaff;" > <body style ="background-color: #afcaff;" >
......
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