Commit 32e85c05 authored by Miguel Luis D. Bandelaria's avatar Miguel Luis D. Bandelaria

resolved cache and database issues and additions

parents cfae5e1b cafd0ea5
{% extends "forum/base.html" %}
{% extends "base.html" %}
{% block page-title %}Details{% endblock %}
{% block content %}
<h1>{{ post.post_title }}</h1>
......
{% extends "forum/base.html" %}
{% extends "base.html" %}
{% block page-title %}Forum Posts{% endblock %}
{% block content%}
<h2>Forum Posts:</h2>
......
from django.forms import ModelForm
from .models import WidgetUser, Department
class UserForm(ModelForm):
class Meta:
model = WidgetUser
fields = ["last_name", "first_name",
"middle_name", "id_num",
"email", "department",
"profile_url"]
# Generated by Django 4.0.3 on 2022-04-05 11:02
# Generated by Django 4.0.3 on 2022-05-15 15:43
import django.core.validators
from django.db import migrations, models
......@@ -11,6 +11,11 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='profile_url',
field=models.FileField(null=True, upload_to='homepage/static/'),
),
migrations.AlterField(
model_name='widgetuser',
name='id_num',
......
# Generated by Django 4.0.3 on 2022-05-07 00:47
# Generated by Django 4.0.3 on 2022-05-15 16:36
from django.db import migrations, models
......@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0013_rename_profile_widgetuser_profile_url'),
('homepage', '0007_widgetuser_profile_url_alter_widgetuser_id_num'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.ImageField(null=True, upload_to='homepage/static/'),
field=models.FileField(null=True, upload_to='static/'),
),
]
# Generated by Django 4.0.3 on 2022-05-06 09:01
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0007_alter_widgetuser_id_num'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='homeunit',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='homeunit', to='homepage.department'),
),
]
# Generated by Django 4.0.3 on 2022-05-06 09:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0008_widgetuser_homeunit'),
]
operations = [
migrations.RemoveField(
model_name='widgetuser',
name='homeunit',
),
]
# Generated by Django 4.0.3 on 2022-05-06 14:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0009_remove_widgetuser_homeunit'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='profile',
field=models.ImageField(null=True, upload_to='homepage/static/homepage/'),
),
]
# Generated by Django 4.0.3 on 2022-05-06 15:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0010_widgetuser_profile'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile',
field=models.TextField(),
),
]
# Generated by Django 4.0.3 on 2022-05-06 15:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0011_alter_widgetuser_profile'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile',
field=models.TextField(null=True),
),
]
# Generated by Django 4.0.3 on 2022-05-06 15:09
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0012_alter_widgetuser_profile'),
]
operations = [
migrations.RenameField(
model_name='widgetuser',
old_name='profile',
new_name='profile_url',
),
]
# Generated by Django 4.0.3 on 2022-05-07 01:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0014_alter_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.ImageField(null=True, upload_to='static/'),
),
]
# Generated by Django 4.0.3 on 2022-05-07 01:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0015_alter_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.ImageField(null=True, upload_to='homepage/static/'),
),
]
# Generated by Django 4.0.3 on 2022-05-07 02:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0016_alter_widgetuser_profile_url'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='profile_url',
field=models.FileField(null=True, upload_to='homepage/static/'),
),
]
......@@ -19,7 +19,7 @@ class WidgetUser(models.Model):
on_delete=models.CASCADE,
null=True,
related_name='department')
profile_url = models.FileField(upload_to='homepage/static/', null=True)
profile_url = models.FileField(upload_to='static/', null=True)
def __str__(self):
return self.first_name
......
{% extends "base.html" %}
{% block page-title %}Add Widget User{% endblock %}
{% block content %}
<div style = "position: relative; left:80px; top:30px;">
<h1>ADD WIDGET USER</h1>
</div>
<div style = "position: relative; left:80px; top:30px;">
<form method="POST" action ="{% url 'homepage:add' %}" enctype="multipart/form-data">
{% csrf_token %}
{{ user_form.as_p }}
<button class="button" type="Save New User">Save New User</button>
<button onclick="location.href = '/homepage'">Return to Homepage</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css"
href="{% static 'homepage/style.css' %}">
<title>Website</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "homepage/base.html" %}
{% extends "base.html" %}
{% block page-title %}Details{% endblock %}
{% block content %}
<div>
......
{% extends "homepage/base.html" %}
{% extends "base.html" %}
{% block page-title %}Widget User Homepage{% endblock %}
{% block content %}
<div style = "position: relative; left:80px; top:30px;">
<h1>WELCOME TO WIDGET!</h1>
</div>
</div>
<div style = "position:relative; left:80px; top:35px;">
<p>Widget Users:
<p>Widget Users:</p>
<p>
{% if widget_user %}
<ol>
{% for user in widget_user %}
<li><a href="/users/{{ user.id_num }}/details/">
{{ user.last_name }}, {{ user.first_name }} {{ user.middle_name }}
</a></li>
{% endfor %}
<button onclick="location.href = '/users/add'">Add Widget User</button>
</ol>
</p>
{% else %}
<p>No users are available.</p>
{% endif %}
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
app_name = 'homepage'
urlpatterns = [
path('homepage/', views.index, name='index'),
path('homepage/', views.HomePageView.as_view(), name='index'),
path('welcome', views.welcome, name='welcome'),
path('users/add/', views.add, name='add'),
path("users/<int:id_num>/details/", views.details, name='details')
]
\ No newline at end of file
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.http import HttpResponse, Http404
from .models import Department, WidgetUser
from .forms import UserForm
from django.views import View
# Create your views here.
def welcome(request):
return HttpResponse('Welcome to Widget!')
def index(request):
class HomePageView(View):
def get(self, request):
widget_user = WidgetUser.objects.order_by("last_name")
context = {
"widget_user": widget_user
}
return render(request, "homepage/index.html", context)
return render(request, "homepage/index.html", {"widget_user": widget_user})
'''
......@@ -36,7 +36,17 @@ def index(request):
def details(request, id_num):
try:
details = WidgetUser.objects.get(pk=id_num)
details = WidgetUser.objects.get(id_num=id_num)
except WidgetUser.DoesNotExist:
raise Http404("User does not exist.")
return render(request, "homepage/details.html", {"details": details})
def add(request):
if request.method == "POST":
user_form = UserForm(request.POST, request.FILES)
if user_form.is_valid():
user_form.save()
return redirect("/homepage")
else:
user_form = UserForm()
return render(request,"homepage/add.html", {"user_form": user_form})
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
......@@ -8,8 +6,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css"
href="{% static 'homepage/style.css' %}">
<title>Website</title>
href="{% static 'style.css' %}">
<title>{% block page-title %}{% endblock %}</title>
</head>
<body>
{% block content %}
......
......@@ -60,7 +60,7 @@ ROOT_URLCONF = 'widget_group_17.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......@@ -124,6 +124,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
......
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