Commit 87c9c6d3 authored by Ramon Angelo Enriquez's avatar Ramon Angelo Enriquez

Added a functional field to upload a profile picture for the new widget user homepage form

parent bb1f3a69
from django import forms
from django.forms import ModelForm from django.forms import ModelForm
from .models import WidgetUser, Department from .models import WidgetUser, Department
......
{% extends "homepage/base.html" %} {% extends "homepage/base.html" %}
{% block content %} {% block content %}
<form class="" action="{% url 'homepage:adduser' %}" method="post"> <form class="" action="{% url 'homepage:adduser' %}" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{{ user_form.as_p }} {{ user_form.as_p }}
<button class="button" type="submit">Save New User</button> <button class="button" type="submit">Save New User</button>
<h3><a href="{% url 'homepage:home' %}">Return to Homepage</a></h3>
</form> </form>
{% endblock %} {% endblock %}
...@@ -4,7 +4,7 @@ from .views import HomepageView, HomepageDetailsView ...@@ -4,7 +4,7 @@ from .views import HomepageView, HomepageDetailsView
app_name = "homepage" app_name = "homepage"
urlpatterns = [ urlpatterns = [
path('', HomepageView.as_view(), name="homepage"), path('', HomepageView.as_view(), name="home"),
path('users/<int:user_id>/details/', HomepageDetailsView.as_view(), name="details"), path('users/<int:user_id>/details/', HomepageDetailsView.as_view(), name="details"),
path('users/add', views.adduser, name="adduser"), path('users/add', views.adduser, name="adduser"),
] ]
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from distutils.command.upload import upload
from tkinter import Widget
from homepage.models import WidgetUser, Department from homepage.models import WidgetUser, Department
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.template import loader from django.template import loader
...@@ -31,7 +33,7 @@ class HomepageDetailsView(View): ...@@ -31,7 +33,7 @@ class HomepageDetailsView(View):
def adduser(request): def adduser(request):
if request.method == "POST": if request.method == "POST":
user_form = UserForm(request.POST) user_form = UserForm(request.POST, request.FILES)
if user_form.is_valid(): if user_form.is_valid():
user_form.save() user_form.save()
return redirect("homepage:adduser") return redirect("homepage:adduser")
......
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