Add button and form to create widget user

parent c0d3b24d
from statistics import mode
from django import forms
from .models import WidgetUser
class WidgetUserForm(forms.ModelForm):
class Meta:
model = WidgetUser
fields = ['last_name', 'first_name', 'middle_name', 'id_num', 'email', 'department', 'image']
\ No newline at end of file
......@@ -22,4 +22,7 @@ class WidgetUser(models.Model):
def __str__(self):
full_name = self.first_name + " " + self.middle_name + " " + self.last_name
return full_name
\ No newline at end of file
return full_name
def get_absolute_url(self):
return u'%d/details' % self.pk
\ No newline at end of file
......@@ -27,4 +27,10 @@
<p>There are no existing users.</p>
{% endif %}
</div>
<div class="add-button">
<a href="{% url 'homepage:userCreate' %}">
<button type="button">Add Widget User</button>
</a>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link rel="stylesheet" type="text/css" href="{% static 'homepage/style.css' %}">
{% endblock %}
{% block title %}{{object.pk}}{% endblock %}
{% block content %}
<nav class="topnav">
<a href="{% url 'homepage:indexHomepage' %}">Homepage</a>
<a href="{% url 'announcements:indexAnnouncements' %}">Announcements</a>
<a href="{% url 'forum:indexForum' %}">Forum</a>
<a href="{% url 'assignments:indexAssignments' %}">Assignments</a>
</nav>
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
......@@ -4,5 +4,6 @@ from . import views
app_name = "homepage"
urlpatterns = [
path('', views.index, name="indexHomepage"),
path('<int:pk>/details', views.UserDetailView.as_view(), name="userDetails")
path('users/<int:pk>/details', views.UserDetailView.as_view(), name="userDetails"),
path('users/add', views.UserCreateView.as_view(), name="userCreate")
]
\ No newline at end of file
from django.http import Http404
from multiprocessing import context
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from .models import WidgetUser
def index(request):
......@@ -12,4 +13,8 @@ def index(request):
return render(request, "homepage/index.html", context)
class UserDetailView(DetailView):
model = WidgetUser
\ No newline at end of file
model = WidgetUser
class UserCreateView(CreateView):
model = WidgetUser
fields = ['last_name', 'first_name', 'middle_name', 'id_num', 'email', 'department', 'image']
\ No newline at end of file
......@@ -52,7 +52,6 @@ body::-webkit-scrollbar {
margin: auto;
width: 20%;
padding: 30px 70px;
margin-bottom: 100px;
color: white;
border-top: 1px solid white;
border-bottom: 1px solid white;
......@@ -180,9 +179,31 @@ a:hover {
h1.welcome {
font-size: 7vw;
margin: 14vh 0 9vh 0;
margin: 9vh 0;
padding: 1vh 0 1vh 0;
color: white;
font-family: "Inter";
background-color: #121212;
}
.add-button {
text-align: center;
}
.add-button > a {
display: inline-block;
margin: 20px auto;
}
button {
background-color: #121212;
color: white;
border: 0px;
border-radius: 10px;
padding: 10px 20px;
font: 15px 'Inter';
}
button:hover {
color: #e1bb54;
}
\ No newline at end of file
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