Skip to content

Commit

Permalink
Added Course Page and Email invite to students function
Browse files Browse the repository at this point in the history
  • Loading branch information
aashutoshrathi committed Oct 30, 2018
1 parent 6753c36 commit cdf19f1
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 122 deletions.
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ ALLOWED_HOSTS=.localhost, .herokuapp.com
SKEY=AddYourSecretKey
G_KEY=
G_SKEY=
EMAIL_USE_TLS=True
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_HOST_USER=YourEmail
EMAIL_HOST_PASSWORD=YourPassword
8 changes: 7 additions & 1 deletion brutus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@
SOCIAL_AUTH_RAISE_EXCEPTIONS = False
SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = ['email']

EMAIL_USE_TLS = config('EMAIL_USE_TLS')
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
EMAIL_PORT = config('EMAIL_PORT')

LOGIN_URL = 'land'
LOGOUT_URL = 'logout'
LOGIN_REDIRECT_URL = 'home'
LOGIN_REDIRECT_URL = 'home'
6 changes: 3 additions & 3 deletions brutus/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
urlpatterns = [
url(r'^$', views.land, name='land'),
url(r'^home/$', views.home, name='home'),
url(r'^upgrade/', views.upgrade, name='upgrade'),
url(r'^add_course/', views.AddCourseView.as_view(), name='add_course'),
url(r'^course/(?P<course>[\w\-]+)/(?P<session>[\w\-]+)/$', views.course_detail, name='course_detail'),
url(r'^list_course/', views.ListCourseView.as_view(), name='list_course'),
path('admin/', admin.site.urls),
url(r'^logout/$', auth_views.LogoutView.as_view(template_name="registration/login.html"), name='logout'),
url(r'^oauth/', include('social_django.urls', namespace='social')),
url(r'^teach/(?P<teacher>[\w\-]+)/(?P<course>[\w\-]+)/$', views.teach_course, name='teach'),
url(r'^leave/(?P<teacher>[\w\-]+)/(?P<course>[\w\-]+)/$', views.leave_course, name='leave'),
url(r'^teach/(?P<teacher>[\w\-]+)/(?P<course>[\w\-]+)/(?P<session>[\w\-]+)/$', views.teach_course, name='teach'),
url(r'^leave/(?P<teacher>[\w\-]+)/(?P<course>[\w\-]+)/(?P<session>[\w\-]+)/$', views.leave_course, name='leave'),
]
4 changes: 4 additions & 0 deletions landing/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def __init__(self, *args, **kwargs):
'placeholder': 'CSX0X or ITX0X'
})

self.fields['target_batch'].widget.attrs.update({
'class': 'uk-input uk-width-auto',
})

self.fields['session'].widget.attrs.update({
'class': 'uk-select uk-width-auto',
'placeholder': '20XX-XY'
Expand Down
31 changes: 19 additions & 12 deletions landing/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datetime
import uuid
from django.contrib.auth.models import User
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
Expand All @@ -16,11 +18,7 @@ class Meta:
avatar_small = models.URLField(null=True, blank=True, help_text='Profile picture smaller URL')

def __str__(self):
return self.user.first_name

def get_fullname(self):
full_name = '%s %s' % (self.user.first_name, self.user.last_name)
return full_name.strip()
return '%s %s' % (self.user.first_name, self.user.last_name)

@property
def roll_no(self):
Expand All @@ -38,24 +36,31 @@ def save_user_profile(sender, instance, **kwargs):
instance.profile.save()


def current_year():
return datetime.date.today().year


class Session(models.Model):
class Meta:
ordering = ('type',)
verbose_name = 'Session'
verbose_name_plural = 'Session'
unique_together = ("type", "start_date")
unique_together = ("type", "year")

SESSION_CHOICES = (
('a', 'Autumn'),
('w', 'Winter'),
)

type = models.CharField(max_length=20, choices=SESSION_CHOICES)
start_date = models.DateField()
year = models.IntegerField(default=current_year, validators=[
MinValueValidator(current_year()),
MaxValueValidator(2100)
])

def __str__(self):
sessions = {'a': 'Autumn', 'w':'Winter'}
return sessions[self.type] + "-" + self.start_date.strftime('%Y')
return sessions[self.type] + "-" + str(self.year)


class Course(models.Model):
Expand All @@ -66,9 +71,11 @@ class Meta:
unique_together = ("code", "session")

name = models.CharField(max_length=50)
code = models.CharField(max_length=10, primary_key=True, help_text="Unique Course Code")
code = models.CharField(max_length=10, help_text="Unique Course Code")
session = models.ForeignKey(Session, on_delete=models.CASCADE, help_text="Session when this course is to be taught")
target_batch = models.IntegerField(help_text="Year when target batch will graduate", default=2020)
target_batch = models.IntegerField(help_text="Year when target batch will graduate", default=2020, validators=[
MinValueValidator(2019),
MaxValueValidator(2104)])

def __str__(self):
return str(self.session) + " " + self.name
Expand All @@ -82,7 +89,7 @@ class Meta:

BRANCH_CHOICES = (
('51', 'B.Tech CSE'),
('52' , 'B.Tech IT'),
('52', 'B.Tech IT'),
('61', 'M.Tech CSE'),
('62', 'M.Tech IT'),
('71', 'Ph.D.'),
Expand Down Expand Up @@ -111,7 +118,7 @@ class Meta:
course = models.ManyToManyField(Course, related_name='teacher_course')

def __str__(self):
return self.profile.user.first_name
return str(self.profile)


class Assistant(models.Model):
Expand Down
8 changes: 0 additions & 8 deletions landing/templates/landing/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/uikit.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/uikit-rtl.min.css' %}">
<link href="https://fonts.googleapis.com/css?family=Niramit" rel="stylesheet">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script type="text/javascript" src="{% static 'js/uikit.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/uikit-icons.min.js' %}"></script>
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>
<body class="uk-overflow-hidden">
<header>
<div uk-sticky="show-on-up: true; sel-target: .uk-navbar-container; cls-active: uk-navbar-sticky; bottom: #transparent-sticky-navbar; animation: uk-animation-slide-top;">
Expand All @@ -49,11 +46,6 @@
<li class="uk-active">
<a>{{ user.username }}</a>
</li>
{% if upgd and not user.profile.teacher_profile %}
<li class="uk-active">
<a href="{% url 'upgrade' %}">Upgrade to Teacher</a>
</li>
{% endif %}
<li class="uk-active">
<a href="{% url 'logout' %}">Logout</a>
</li>
Expand Down
85 changes: 85 additions & 0 deletions landing/templates/landing/course_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{% extends 'landing/base.html' %}
{% load static %}

{% block title %}
Labper | {{ page_title }}
{% endblock %}

{% block body %}
<div class="uk-card-hover uk-button uk-card-secondary uk-light uk-border-rounded uk-card-default uk-card-body uk-width-2-3@l uk-margin-top uk-align-center ">
<p class="uk-badge uk-float-left uk-padding-small">Batch: {{course.target_batch}}</p>
{% if user.profile.teacher_profile %}
<a class="uk-text-center uk-float-right uk-border-pill uk-width-auto uk-button uk-button-primary">Add Assistant</a>
{% endif %}
<h3 class="uk-card-title">{{ course.name }} ({{course.code}})</h3>
{% if user.profile.teacher_profile %}
<a class="uk-text-center uk-margin-small uk-margin-remove-bottom uk-button uk-float-right uk-border-pill uk-width-auto uk-button uk-button-primary">Add Studnets</a>
{% endif %}
<p><span class="uk-text-bold">Instructor:</span>
{{ teachers.all | join:", " }}
</p>
</div>
<div class="uk-card-hover uk-card-secondary uk-light uk-border-rounded uk-card-default uk-card-body uk-width-2-3@m uk-margin-top uk-align-center ">
<ul class="uk-tab-bottom" uk-tab uk-switcher>
<li class="uk-active"><a href="#">Summary</a></li>
<li><a href="#">Students</a></li>
<li><a href="#">Instructors</a></li>
</ul>
<ul class="uk-switcher uk-margin">
<li>
<p class="uk-text-meta">Course events will be added here</p>
<div class="uk-card-hover uk-card-secondary uk-border-rounded uk-card-default uk-card-body uk-width-1-1@m uk-margin-top uk-align-center ">
<a class="uk-text-center uk-float-right uk-border-pill uk-width-auto uk-button uk-button-primary">Submit</a>
<h3 class="uk-card-title">Example Lab</h3>
<hr>
<p class="uk-float-right">Deadline: 11:59 PM, 1st Nov 2018</p>
<p>Example Description for the lab</p>
</div>
</li>
<li>
<p class="uk-text-meta">List of students who are part of course is here.</p>
<table class="uk-table uk-table-striped">
<tbody>
{% for student in students %}
<tr>
<td>
<a href="#">
{% if student.profile.avatar_small %}
<img src="{{ student.profile.avatar_small }}" class="uk-border-circle uk-margin-left" width="40">
{% else %}
<img src="{% static 'images/default.ico' %}" class="uk-border-circle" width="40">
{% endif %}
</a>
</td>
<td class="uk-text-middle">{{ student.profile }}</td>
<td class="uk-text-middle">{{ student.profile.user.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</li>
<li>
<table class="uk-table uk-table-striped">
<tbody>
{% for teacher in teachers %}
<tr>
<td>
<a href="#">
{% if teacher.profile.avatar_small %}
<img src="{{ teacher.profile.avatar_small }}" class="uk-border-circle uk-margin-left" width="40">
{% else %}
<img src="{% static 'images/default.ico' %}" class="uk-border-circle" width="40">
{% endif %}
</a>
</td>
<td class="uk-text-middle">{{ teacher.profile }}</td>
<td class="uk-text-middle">Course Instructor</td>
<td class="uk-text-middle">{{ teacher.profile.user.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</li>
</ul>
</div>
{% endblock %}
51 changes: 0 additions & 51 deletions landing/templates/landing/course_list.html

This file was deleted.

38 changes: 18 additions & 20 deletions landing/templates/landing/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{% endblock %}

{% block body %}
<p class="uk-text-center uk-text-lead">Current Session: {{session}} </p>
{% if user.profile.teacher_profile %}
<div class="uk-text-center" uk-grid>
<div class="uk-width-1-3">
Expand All @@ -23,6 +24,7 @@ <h3 class="uk-card-title">My Courses</h3>
<tr>
<th class="uk-text-center">Code</th>
<th class="uk-text-center">Batch</th>
<th class="uk-text-center">Session</th>
<th class="uk-text-center">Name</th>
</tr>
</thead>
Expand All @@ -31,23 +33,21 @@ <h3 class="uk-card-title">My Courses</h3>
<tr>
<td>{{ course.code }}</td>
<td>{{ course.target_batch }}</td>
<td>{{ course.name }}</td>
<td>{{ course.session }}</td>
<td><a class="uk-link-text" href="{% url 'course_detail' course=course.code session=course.session.id %}">{{ course.name }}<a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="uk-text-center"> You have no courses :( </p>
<p class="uk-text-center"> You have no courses :( </p>
{% endif %}
</div>
</div>
<div class="uk-width-1-3">
<div class="uk-card uk-card-default uk-card-body">
<h3 class="uk-card-title">Actions</h3>
<hr>
<a class="uk-text-center text-white uk-border-pill uk-width-auto uk-button uk-button-primary">Add TA</a>
<a class="uk-text-center uk-margin text-white uk-border-pill uk-width-auto uk-button uk-button-primary">Add Students</a>
<br>
<a href="{% url 'list_course' %}" class="uk-text-center text-white uk-border-pill uk-button uk-button-secondary">Choose Courses</a>
<a href="{% url 'add_course' %}" class="uk-text-center text-white uk-border-pill uk-button uk-button-secondary">Add Courses</a>
</div>
Expand All @@ -70,37 +70,35 @@ <h3 class="uk-card-title">Summary</h3>
<hr>
</div>
</div>
<div class="uk-width-1-3">
<div class="uk-width-2-3">
<div class="uk-card uk-card-default uk-card-body">
<h3 class="uk-card-title">My Courses</h3>
<p class="uk-text-meta">Your enrolled courses</p>
<hr>
{% if courses %}
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th class="uk-text-center">Code</th>
<th class="uk-text-center">Batch</th>
<th class="uk-text-center">Session</th>
<th class="uk-text-center">Name</th>
</tr>
</thead>
<tbody>
{% for course in courses %}
<tr>
<td>CS305</td>
<td>2020</td>
<td>Automata Theory</td>
<td>{{ course.code }}</td>
<td>{{ course.target_batch }}</td>
<td>{{ course.session }}</td>
<td><a class="uk-link-text" href="{% url 'course_detail' course=course.code session=course.session.id %}">{{ course.name }}<a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="uk-width-1-3">
<div class="uk-card uk-card-default uk-card-body">
<h3 class="uk-card-title">Actions</h3>
<p class="uk-text-meta">Few actions to make your life easier</p>
<hr>
<a class="uk-text-center uk-margin text-white uk-border-pill uk-width-auto uk-button uk-button-primary">Submit Assignments</a>
<br>
<a class="uk-text-center text-white uk-border-pill uk-button uk-button-secondary">Previous Submissions</a>
</table>
{% else %}
<p class="uk-text-center"> You have no courses :( </p>
{% endif %}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit cdf19f1

Please sign in to comment.