This commit is contained in:
Praneeth Bhandaru 2020-12-13 13:17:48 -05:00
parent cf875ed687
commit abd4dc4f54
6 changed files with 200 additions and 7 deletions

View File

@ -10,7 +10,7 @@ class UserRegisterForm(UserCreationForm):
class Meta:
model = User
fields = ["username", "email", "password1", "password2"]
fields = ["username", "email", "first_name", "last_name", "password1", "password2"]
def __init__(self, *args, **kwargs):
super(UserRegisterForm, self).__init__(*args, **kwargs)

View File

@ -35,5 +35,6 @@ urlpatterns = [
path("create_user/", register_view, name="create_user"),
path("", home_view, name="home"),
path("classes", class_form_view, name="classroom_form"),
path("classes/<int:id>", classroom_view, name="class")
path("classes/<int:id>", classroom_view, name="class"),
path("classes/<int:id>/edit", classroom_edit_view, name="edit_class"),
]

View File

@ -60,8 +60,28 @@ def class_form_view(request):
return render(request, "frontend/classroomForm.html", {"form": form})
@login_required
def classroom_view(request, id):
classroom = Classroom.objects.get(id=id)
if classroom.student.user.pk != request.user.pk:
return HttpResponseForbidden('You do not have access to this class')
return render(request, "frontend/class.html", {'class': classroom})
def classroom_edit_view(request, id):
classroom = Classroom.objects.get(id=id)
if classroom.student.user.pk != request.user.pk:
return HttpResponseForbidden('You do not have access to this class')
if request.method == 'POST':
form = ClassroomForm(request.POST, instance=classroom)
if form.is_valid():
classroom = form.save()
classroom.save()
return redirect(f'out/classes/{id}')
form = ClassroomForm(instance=classroom)
return render(request, 'frontend/editClassroom.html', {'form': form})

View File

@ -2,14 +2,39 @@
{% load static %}
{% block content %}
<section class="mbr-section content4 cid-qxVpIJ8WtD" id="content4-na" data-rv-view="8245" style="min-height: 100vh;">
<section class="header11 cid-qv7jHqwEI9 mbr-fullscreen mbr-parallax-background" id="header11-5p" data-rv-view="9263" style="background-image: url('{% static 'images/class.png' %}');">
<!-- Block parameters controls (Blue "Gear" panel) -->
<!-- End block parameters -->
<div class="mbr-overlay" style="opacity: 0.5; background-color: rgb(35, 35, 35);">
</div>
<div class="container align-left">
<div class="media-container-column mbr-white col-md-12">
<h1 class="mbr-section-title py-3 mbr-fonts-style display-1"><strong>Welcome to your class page for {{ class.name }}</strong>
</h1>
<p class="mbr-text py-3 mbr-fonts-style display-5">
You can view and edit your class information here!</p>
<div class="mbr-section-btn py-4">
<a class="btn btn-md btn-white-outline display-4"
href="/out/classes/{{ class.id }}/edit">EDIT</a>
</div>
<br>
</div>
<div class="media-container-column mbr-white col-md-12 m-t-10 p-t-10"><div class='icon-scroll'><div/></div>
</div>
</section>
<section class="mbr-section content4 cid-qxVpIJ8WtD" id="content4-na" data-rv-view="8245">
<div class="container">
<div class="media-container-row">
<div class="title col-12 col-md-8">
<h2 class="align-center pb-3 mbr-fonts-style display-2">
Your Class: {{ class.name }}</h2>
</h2>
</div>
</div>
<hr style="border-color: white;">
@ -17,6 +42,16 @@
<div class="class_cont container class center centered m-10">
<h3>Teacher: {{ class.teacher }}</h3>
</div>
<br><br><br><br>
<div class="class_cont container class center centered m-10">
<h3>Period: {{ class.period }}</h3>
</div>
<br><br><br><br>
<div class="class_cont container class center centered m-10">
<h3><a href="{{ class.link }}">Click here to navigate to your class!</a></h3>
</div>
</div>
</section>
{% endblock content %}
@ -28,5 +63,60 @@
.class_cont {
text-align: center;
}
</style>
<style>
.classes{
color: white;
}
.class_cont {
text-align: center;
}
hr {
border-color: white;
}
.icon-scroll,
.icon-scroll:before {
position: absolute;
left: 50%;
top: 90%;
}
.icon-scroll {
width: 40px;
height: 70px;
margin-left: -20px;
top: 50%;
margin-top: -35px;
box-shadow: inset 0 0 0 1px #fff;
border-radius: 25px;
}
.icon-scroll:before {
content: '';
width: 8px;
height: 8px;
background: #fff;
margin-left: -4px;
top: 8px;
border-radius: 4px;
animation-duration: 1.5s;
animation-iteration-count: infinite;
animation-name: scroll;
}
@keyframes scroll {
0% {
opacity: 1;
}
100% {
opacity: 0;
transform: translateY(46px);
}
}
</style>
{% endblock %}

View File

@ -0,0 +1,80 @@
{% extends 'frontend/index.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block head %}
<link rel="stylesheet" type="text/css" href="{% static "login/css/index.css" %}"
/><!--===============================================================================================-->
<link rel="icon" type="image/png" href="{% static "login/images/icons/favicon.ico" %}"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/vendor/bootstrap/css/bootstrap.min.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/fonts/font-awesome-4.7.0/css/font-awesome.min.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/fonts/iconic/css/material-design-iconic-font.min.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/vendor/animate/animate.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/vendor/css-hamburgers/hamburgers.min.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/vendor/animsition/css/animsition.min.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/vendor/select2/select2.min.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/vendor/daterangepicker/daterangepicker.css" %}">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="{% static "login/css/util.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "login/css/main.css" %}">
<!--===============================================================================================-->
{% endblock head %}
{% block content %}
<div class="login_container">
<div class="container-login100" style="background-image: url("{% static 'login/images/bg-01.jpg' %}");">
<div class="wrap-login100 p-l-55 p-r-55 p-t-80 p-b-30">
<form class="login100-form validate-form" method="POST">
{% csrf_token %}
<span class="login100-form-title p-b-37">
Edit Class
</span>
{% for field in form %}
<div class="wrap-input100 validate-input m-b-10" data-validate="Enter {{ field.label }}">
<p style="color: red;">{{ field.errors }}</p>
<input type="{{ field.field.widget.input_type}}" name="{{ field.html_name }}" id="{{ field.auto_id }}" required class="input100" placeholder="{{ field.label }}">
<span class="focus-input100"></span>
</div>
{% endfor %}
<div class="container-login100-form-btn m-b-10">
<button class="login100-form-btn">
Edit!
</button>
</div>
</form>
</div>
</div>
<div id="dropDownSelect1"></div>
{% endblock content %}
{% block js %}
<!--===============================================================================================-->
<script src="{% static "login/vendor/jquery/jquery-3.2.1.min.js" %}"></script>
<!--===============================================================================================-->
<script src="{% static "login/vendor/animsition/js/animsition.min.js" %}"></script>
<!--===============================================================================================-->
<script src="{% static "login/vendor/bootstrap/js/popper.js" %}"></script>
<script src="{% static "login/vendor/bootstrap/js/bootstrap.min.js" %}"></script>
<!--===============================================================================================-->
<script src="{% static "login/vendor/select2/select2.min.js" %}"></script>
<!--===============================================================================================-->
<script src="{% static "login/vendor/daterangepicker/moment.min.js" %}"></script>
<script src="{% static "login/vendor/daterangepicker/daterangepicker.js" %}"></script>
<!--===============================================================================================-->
<script src="{% static "login/vendor/countdowntime/countdowntime.js" %}"></script>
<!--===============================================================================================-->
<script src="{% static "login/js/main.js" %}"></script>
{% endblock js %}

View File

@ -2,7 +2,7 @@
{% load static %}
{% block content %}
<section class="header11 cid-qv7jHqwEI9 mbr-fullscreen mbr-parallax-background" id="header11-5p" data-rv-view="9263">
<section class="header11 cid-qv7jHqwEI9 mbr-fullscreen mbr-parallax-background" id="header11-5p" data-rv-view="9263" style="background-image: url('{% static 'images/space.png' %}');">
<!-- Block parameters controls (Blue "Gear" panel) -->
@ -47,8 +47,10 @@
<br>
<br>
<div class="class_cont">
<a href="/out/classes/{{ user_class.id }}"><h1>{{ user_class.name }}</h1></a>
<h3>{{ user_class.teacher }}; &emsp; Period: {{ user_class.period }}</h3>
<a href="/out/classes/{{ user_class.id }}" style="text-decoration: underline; color: white;"><h1><b> {{ user_class.name }} </b></h1></a>
<br>
<h3>{{ user_class.teacher }}</h3>
<h3>Period: {{ user_class.period }}</h3>
</div>
{% endfor %}
</div>