From 379d04803c59b350b7061ab2557542449aafc0e8 Mon Sep 17 00:00:00 2001
From: Akshen
Date: Tue, 7 Feb 2017 11:38:28 +0530
Subject: Initial Commit
---
workshop_app/__init__.py | 0
workshop_app/admin.py | 3 +++
workshop_app/apps.py | 7 +++++++
workshop_app/migrations/__init__.py | 0
workshop_app/models.py | 5 +++++
workshop_app/tests.py | 3 +++
workshop_app/views.py | 3 +++
7 files changed, 21 insertions(+)
create mode 100644 workshop_app/__init__.py
create mode 100644 workshop_app/admin.py
create mode 100644 workshop_app/apps.py
create mode 100644 workshop_app/migrations/__init__.py
create mode 100644 workshop_app/models.py
create mode 100644 workshop_app/tests.py
create mode 100644 workshop_app/views.py
(limited to 'workshop_app')
diff --git a/workshop_app/__init__.py b/workshop_app/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/workshop_app/admin.py b/workshop_app/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/workshop_app/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/workshop_app/apps.py b/workshop_app/apps.py
new file mode 100644
index 0000000..dc9a567
--- /dev/null
+++ b/workshop_app/apps.py
@@ -0,0 +1,7 @@
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class WorkshopAppConfig(AppConfig):
+ name = 'workshop_app'
diff --git a/workshop_app/migrations/__init__.py b/workshop_app/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/workshop_app/models.py b/workshop_app/models.py
new file mode 100644
index 0000000..bd4b2ab
--- /dev/null
+++ b/workshop_app/models.py
@@ -0,0 +1,5 @@
+from __future__ import unicode_literals
+
+from django.db import models
+
+# Create your models here.
diff --git a/workshop_app/tests.py b/workshop_app/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/workshop_app/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/workshop_app/views.py b/workshop_app/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/workshop_app/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
--
cgit
From 8a2bd288c77ce3165518f7bf1eff75825b4db5b3 Mon Sep 17 00:00:00 2001
From: Akshen
Date: Tue, 14 Feb 2017 14:01:37 +0530
Subject: Basic Login Done
---
workshop_app/admin.py | 2 +
workshop_app/models.py | 26 +++++++++--
workshop_app/views.py | 120 ++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 143 insertions(+), 5 deletions(-)
(limited to 'workshop_app')
diff --git a/workshop_app/admin.py b/workshop_app/admin.py
index 8c38f3f..53d8ad5 100644
--- a/workshop_app/admin.py
+++ b/workshop_app/admin.py
@@ -1,3 +1,5 @@
from django.contrib import admin
+from .models import Profile
# Register your models here.
+admin.site.register(Profile)
\ No newline at end of file
diff --git a/workshop_app/models.py b/workshop_app/models.py
index bd4b2ab..07db83a 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -1,5 +1,25 @@
-from __future__ import unicode_literals
-
+#from __future__ import unicode_literals
from django.db import models
+from django.contrib.auth.models import User
+
+position_choices = (
+ ("student", "Student"),
+ ("instructor", "Instructor")
+ )
+
+class Profile(models.Model):
+ """Profile for users"""
+
+ user = models.OneToOneField(User)
+ institute = models.CharField(max_length=150)
+ department = models.CharField(max_length=150)
+ position = models.CharField(max_length=32, choices=position_choices)
+
+ def __str__(self):
+ return u"{0} {1} | {2}".format(self.user.first_name, self.user.last_name, self.user.email)
+
+
+def has_profile(user):
+ """ check if user has profile """
+ return True if hasattr(user, 'profile') else False
-# Create your models here.
diff --git a/workshop_app/views.py b/workshop_app/views.py
index 91ea44a..334a1dc 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -1,3 +1,119 @@
-from django.shortcuts import render
+from django.shortcuts import render, redirect
+from forms import UserRegistrationForm, UserLoginForm, ProfileForm
+from .models import Profile, User, has_profile
+from django.template import RequestContext
+from django.contrib.auth import login, logout, authenticate
+from django.contrib.auth.decorators import login_required
+from django.contrib import messages
-# Create your views here.
+
+def home(request):
+ '''Home'''
+ return render(request, "home.html")
+
+def is_instructor(user):
+ '''Check if the user is having instructor rights'''
+ if user.groups.filter(name='instructor').exists():
+ return True
+
+def user_login(request):
+ '''Login'''
+ user = request.user
+ if user.is_authenticated():
+ if user.groups.filter(name='instructor').count() > 0:
+ return redirect('/manage/')
+ return redirect('/view_profile/')
+
+ if request.method == "POST":
+ form = UserLoginForm(request.POST)
+ if form.is_valid():
+ user = form.cleaned_data
+ login(request, user)
+ if user.groups.filter(name='instructor').count() > 0:
+ return redirect('/manage/')
+ return redirect('/view_profile/')
+ else:
+ return render(request, 'workshop_app/login.html', {"form": form})
+ else:
+ form = UserLoginForm()
+ return render(request, 'workshop_app/login.html', {"form": form})
+
+def user_logout(request):
+ '''Logout'''
+ logout(request)
+ return render(request, 'workshop_app/logout.html')
+
+def user_register(request):
+ '''User Registeration form'''
+ if request.method == 'POST':
+ form = UserRegistrationForm(request.POST)
+ if form.is_valid():
+ data = form.cleaned_data
+ username, password = form.save()
+ new_user = authenticate(username=username, password=password)
+ login(request, new_user)
+ return redirect('/home')
+ else:
+ return render(request, "workshop_app/register.html", {"form": form})
+ else:
+ form = UserRegistrationForm()
+
+ return render(request, "workshop_app/register.html", {"form": form})
+
+
+def book(request):
+ user = request.user
+ if user.is_authenticated():
+ if user.groups.filter(name='instructor').count() > 0:
+ return redirect('/manage/')
+ return render(request, "workshop_app/booking.html")
+ else:
+ return redirect('/login/')
+
+def manage(request):
+ user = request.user
+ if user.is_authenticated():
+ if user.groups.filter(name='instructor').count() > 0:
+ return render(request, "workshop_app/manage.html")
+ return redirect('/book/')
+ else:
+ return redirect('/login/')
+
+@login_required
+def view_profile(request):
+ """ view moderators and users profile """
+ return render(request, "workshop_app/view_profile.html")
+
+@login_required
+def edit_profile(request):
+ """ edit profile details facility for instructor and students """
+
+ user = request.user
+ if is_instructor(user):
+ template = 'workshop_app/manage.html'
+ else:
+ template = 'workshop_app/user.html'
+ context = {'template': template}
+ if has_profile(user):
+ profile = Profile.objects.get(user_id=user.id)
+ else:
+ profile = None
+
+ if request.method == 'POST':
+ form = ProfileForm(request.POST, user=user, instance=profile)
+ if form.is_valid():
+ form_data = form.save(commit=False)
+ form_data.user = user
+ form_data.user.first_name = request.POST['first_name']
+ form_data.user.last_name = request.POST['last_name']
+ form_data.user.save()
+ form_data.save()
+
+ return render(request, 'workshop_app/profile_updated.html', context)
+ else:
+ context['form'] = form
+ return my_render_to_response('workshop_app/edit_profile.html', context)
+ else:
+ form = ProfileForm(user=user, instance=profile)
+ context['form'] = form
+ return render(request, 'workshop_app/edit_profile.html', context)
--
cgit
From 39573ea6c7b15f863436355b2587d02d50373bf5 Mon Sep 17 00:00:00 2001
From: Akshen
Date: Thu, 16 Feb 2017 12:07:19 +0530
Subject: Courses Model Added
---
workshop_app/admin.py | 5 +++--
workshop_app/models.py | 17 +++++++++++++++--
workshop_app/views.py | 23 +++++++++++++++++------
3 files changed, 35 insertions(+), 10 deletions(-)
(limited to 'workshop_app')
diff --git a/workshop_app/admin.py b/workshop_app/admin.py
index 53d8ad5..5a4da13 100644
--- a/workshop_app/admin.py
+++ b/workshop_app/admin.py
@@ -1,5 +1,6 @@
from django.contrib import admin
-from .models import Profile
+from .models import Profile, Courses
# Register your models here.
-admin.site.register(Profile)
\ No newline at end of file
+admin.site.register(Profile)
+admin.site.register(Courses)
\ No newline at end of file
diff --git a/workshop_app/models.py b/workshop_app/models.py
index 07db83a..0dbff06 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -2,13 +2,14 @@
from django.db import models
from django.contrib.auth.models import User
+
position_choices = (
- ("student", "Student"),
+ ("coordinator", "Coordinator"),
("instructor", "Instructor")
)
class Profile(models.Model):
- """Profile for users"""
+ """Profile for users(instructors and coordinators)"""
user = models.OneToOneField(User)
institute = models.CharField(max_length=150)
@@ -23,3 +24,15 @@ def has_profile(user):
""" check if user has profile """
return True if hasattr(user, 'profile') else False
+class Courses(models.Model):
+ """"Admin creates courses which can be used by the instructor to create workshops.
+ """
+
+ course_name = models.CharField(max_length=120)
+ course_description = models.TextField()
+ course_duration = models.CharField(max_length=12)
+
+
+ def __str__(self):
+ return u"{0} {1}".format(self.course_name, self.course_duration)
+
diff --git a/workshop_app/views.py b/workshop_app/views.py
index 334a1dc..54dc43d 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -7,9 +7,10 @@ from django.contrib.auth.decorators import login_required
from django.contrib import messages
-def home(request):
- '''Home'''
- return render(request, "home.html")
+
+def index(request):
+ '''Landing Page'''
+ return render(request, "workshop_app/index.html")
def is_instructor(user):
'''Check if the user is having instructor rights'''
@@ -86,13 +87,13 @@ def view_profile(request):
@login_required
def edit_profile(request):
- """ edit profile details facility for instructor and students """
+ """ edit profile details facility for instructor and coordinator """
user = request.user
if is_instructor(user):
template = 'workshop_app/manage.html'
else:
- template = 'workshop_app/user.html'
+ template = 'workshop_app/booking.html'
context = {'template': template}
if has_profile(user):
profile = Profile.objects.get(user_id=user.id)
@@ -112,8 +113,18 @@ def edit_profile(request):
return render(request, 'workshop_app/profile_updated.html', context)
else:
context['form'] = form
- return my_render_to_response('workshop_app/edit_profile.html', context)
+ return render(request, 'workshop_app/edit_profile.html', context)
else:
form = ProfileForm(user=user, instance=profile)
context['form'] = form
return render(request, 'workshop_app/edit_profile.html', context)
+
+@login_required
+def create_workshop(request):
+ '''Instructor creates workshops'''
+
+ user = request.user
+ if is_instructor(user):
+ return render(request, 'workshop_app/create_workshop.html')
+ else:
+ return redirect('/book/')
--
cgit
From 057e1ded6560f03ed5a66885eef452bf3317b645 Mon Sep 17 00:00:00 2001
From: Akshen
Date: Thu, 23 Feb 2017 16:57:35 +0530
Subject: instructor
on hold since looking after PythonExpress model
---
workshop_app/admin.py | 5 +-
workshop_app/forms.py | 127 +++++++++++++++++++++
workshop_app/models.py | 28 ++++-
workshop_app/static/workshop_app/css/modal.css | 20 ++++
.../static/workshop_app/css/sticky-footer.css | 10 ++
workshop_app/static/workshop_app/js/overlay.js | 7 ++
workshop_app/templates/workshop_app/base.html | 52 +++++++++
workshop_app/templates/workshop_app/booking.html | 22 ++++
.../templates/workshop_app/create_workshop.html | 48 ++++++++
.../templates/workshop_app/edit_profile.html | 37 ++++++
workshop_app/templates/workshop_app/index.html | 10 ++
workshop_app/templates/workshop_app/login.html | 20 ++++
workshop_app/templates/workshop_app/logout.html | 16 +++
workshop_app/templates/workshop_app/manage.html | 35 ++++++
.../templates/workshop_app/profile_updated.html | 28 +++++
workshop_app/templates/workshop_app/register.html | 18 +++
.../workshop_app/view_course_details.html | 26 +++++
.../templates/workshop_app/view_course_list.html | 101 ++++++++++++++++
.../templates/workshop_app/view_profile.html | 57 +++++++++
workshop_app/views.py | 64 +++++++++--
20 files changed, 714 insertions(+), 17 deletions(-)
create mode 100644 workshop_app/forms.py
create mode 100644 workshop_app/static/workshop_app/css/modal.css
create mode 100644 workshop_app/static/workshop_app/css/sticky-footer.css
create mode 100644 workshop_app/static/workshop_app/js/overlay.js
create mode 100644 workshop_app/templates/workshop_app/base.html
create mode 100644 workshop_app/templates/workshop_app/booking.html
create mode 100644 workshop_app/templates/workshop_app/create_workshop.html
create mode 100644 workshop_app/templates/workshop_app/edit_profile.html
create mode 100644 workshop_app/templates/workshop_app/index.html
create mode 100644 workshop_app/templates/workshop_app/login.html
create mode 100644 workshop_app/templates/workshop_app/logout.html
create mode 100644 workshop_app/templates/workshop_app/manage.html
create mode 100644 workshop_app/templates/workshop_app/profile_updated.html
create mode 100644 workshop_app/templates/workshop_app/register.html
create mode 100644 workshop_app/templates/workshop_app/view_course_details.html
create mode 100644 workshop_app/templates/workshop_app/view_course_list.html
create mode 100644 workshop_app/templates/workshop_app/view_profile.html
(limited to 'workshop_app')
diff --git a/workshop_app/admin.py b/workshop_app/admin.py
index 5a4da13..b980438 100644
--- a/workshop_app/admin.py
+++ b/workshop_app/admin.py
@@ -1,6 +1,7 @@
from django.contrib import admin
-from .models import Profile, Courses
+from .models import Profile, Course, Workshop
# Register your models here.
admin.site.register(Profile)
-admin.site.register(Courses)
\ No newline at end of file
+admin.site.register(Course)
+admin.site.register(Workshop)
\ No newline at end of file
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
new file mode 100644
index 0000000..3cc0021
--- /dev/null
+++ b/workshop_app/forms.py
@@ -0,0 +1,127 @@
+from django import forms
+from .models import Profile, Course, Workshop
+from string import punctuation, digits, letters
+from django.contrib.auth.models import User
+from django.contrib.auth import authenticate
+
+
+
+UNAME_CHARS = letters + "._" + digits
+PWD_CHARS = letters + punctuation + digits
+
+position_choices = (
+ ("coordinator", "Coordinator"),
+ ("instructor", "Instructor")
+ )
+
+class UserRegistrationForm(forms.Form):
+ """A Class to create new form for User's Registration.
+ It has the various fields and functions required to register
+ a new user to the system"""
+
+ username = forms.CharField(max_length=32, help_text='''Letters, digits,
+ period only.''')
+ email = forms.EmailField()
+ password = forms.CharField(max_length=32, widget=forms.PasswordInput())
+ confirm_password = forms.CharField\
+ (max_length=32, widget=forms.PasswordInput())
+ first_name = forms.CharField(max_length=32)
+ last_name = forms.CharField(max_length=32)
+ institute = forms.CharField\
+ (max_length=128, help_text='Institute/Organization')
+ department = forms.CharField\
+ (max_length=64, help_text='Department you work/study at')
+ position = forms.ChoiceField\
+ (help_text='If you are an instructor please mail us at python[at]fossee[dot]in', choices=position_choices)
+
+ def clean_username(self):
+ u_name = self.cleaned_data["username"]
+ if u_name.strip(UNAME_CHARS):
+ msg = "Only letters, digits, period are"\
+ " allowed in username"
+ raise forms.ValidationError(msg)
+ try:
+ User.objects.get(username__exact=u_name)
+ raise forms.ValidationError("Username already exists.")
+ except User.DoesNotExist:
+ return u_name
+
+ def clean_password(self):
+ pwd = self.cleaned_data['password']
+ if pwd.strip(PWD_CHARS):
+ raise forms.ValidationError("Only letters, digits and punctuation\
+ are allowed in password")
+ return pwd
+
+ def clean_confirm_password(self):
+ c_pwd = self.cleaned_data['confirm_password']
+ pwd = self.data['password']
+ if c_pwd != pwd:
+ raise forms.ValidationError("Passwords do not match")
+
+ return c_pwd
+
+ def save(self):
+ u_name = self.cleaned_data["username"]
+ u_name = u_name.lower()
+ pwd = self.cleaned_data["password"]
+ email = self.cleaned_data['email']
+ new_user = User.objects.create_user(u_name, email, pwd)
+
+ new_user.first_name = self.cleaned_data["first_name"]
+ new_user.last_name = self.cleaned_data["last_name"]
+ new_user.save()
+
+ cleaned_data = self.cleaned_data
+ new_profile = Profile(user=new_user)
+ new_profile.institute = cleaned_data["institute"]
+ new_profile.department = cleaned_data["department"]
+ new_profile.position = cleaned_data["position"]
+
+ new_profile.save()
+
+ return u_name, pwd
+
+class UserLoginForm(forms.Form):
+ """Creates a form which will allow the user to log into the system."""
+
+ username = forms.CharField(max_length=32)
+ password = forms.CharField(max_length=32, widget=forms.PasswordInput())
+
+ def clean(self):
+ super(UserLoginForm, self).clean()
+ try:
+ u_name, pwd = self.cleaned_data["username"],\
+ self.cleaned_data["password"]
+ user = authenticate(username=u_name, password=pwd)
+ except Exception:
+ raise forms.ValidationError\
+ ("Username and/or Password is not entered")
+ if not user:
+ raise forms.ValidationError("Invalid username/password")
+ return user
+
+class ProfileForm(forms.ModelForm):
+ """ profile form for coordinator and instructor """
+
+ class Meta:
+ model = Profile
+ fields = ['first_name', 'last_name', 'institute', 'department',
+ 'position']
+
+ first_name = forms.CharField(max_length=32)
+ last_name = forms.CharField(max_length=32)
+
+ def __init__(self, *args, **kwargs):
+ if 'user' in kwargs:
+ user = kwargs.pop('user')
+ super(ProfileForm, self).__init__(*args, **kwargs)
+ self.fields['first_name'].initial = user.first_name
+ self.fields['last_name'].initial = user.last_name
+
+class CreateWorkshop(forms.ModelForm):
+ """Instructors can create Workshops based on the courses available."""
+
+ class Meta:
+ model = Workshop
+ fields = ['workshop_title', 'date', 'start_time', 'end_time']
\ No newline at end of file
diff --git a/workshop_app/models.py b/workshop_app/models.py
index 0dbff06..9aceb57 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -8,6 +8,12 @@ position_choices = (
("instructor", "Instructor")
)
+
+
+def has_profile(user):
+ """ check if user has profile """
+ return True if hasattr(user, 'profile') else False
+
class Profile(models.Model):
"""Profile for users(instructors and coordinators)"""
@@ -20,11 +26,7 @@ class Profile(models.Model):
return u"{0} {1} | {2}".format(self.user.first_name, self.user.last_name, self.user.email)
-def has_profile(user):
- """ check if user has profile """
- return True if hasattr(user, 'profile') else False
-
-class Courses(models.Model):
+class Course(models.Model):
""""Admin creates courses which can be used by the instructor to create workshops.
"""
@@ -32,7 +34,21 @@ class Courses(models.Model):
course_description = models.TextField()
course_duration = models.CharField(max_length=12)
-
def __str__(self):
return u"{0} {1}".format(self.course_name, self.course_duration)
+
+class Workshop(models.Model):
+ """Instructor Creates workshop based on
+ Courses available"""
+
+ workshop_creator = models.ForeignKey(Profile, on_delete=models.CASCADE)
+ workshop_title = models.ForeignKey(Course, on_delete=models.CASCADE,\
+ help_text='Select the course you would like to create a workshop for')
+ date = models.DateField()
+ start_time = models.TimeField()
+ end_time = models.TimeField()
+ status = models.BooleanField()
+
+ def __str__(self):
+ return u"{0} | {1}".format(self.workshop_title, self.date)
diff --git a/workshop_app/static/workshop_app/css/modal.css b/workshop_app/static/workshop_app/css/modal.css
new file mode 100644
index 0000000..dc767a0
--- /dev/null
+++ b/workshop_app/static/workshop_app/css/modal.css
@@ -0,0 +1,20 @@
+#overlay {
+ visibility: hidden;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ width:100%;
+ height:100%;
+ text-align:center;
+ z-index: 1000;
+}
+
+#overlay div {
+ width:900px;
+ height: 450px;
+ margin: 100px auto;
+ background-color: #fff;
+ border:1px solid #000;
+ padding:15px;
+ text-align:center;
+}
diff --git a/workshop_app/static/workshop_app/css/sticky-footer.css b/workshop_app/static/workshop_app/css/sticky-footer.css
new file mode 100644
index 0000000..42471ee
--- /dev/null
+++ b/workshop_app/static/workshop_app/css/sticky-footer.css
@@ -0,0 +1,10 @@
+.footer {
+ position: absolute;
+ bottom: 0;
+ padding-left: 75px;
+
+}
+
+.hiddenRow {
+ padding: 0 !important;
+}
\ No newline at end of file
diff --git a/workshop_app/static/workshop_app/js/overlay.js b/workshop_app/static/workshop_app/js/overlay.js
new file mode 100644
index 0000000..6563c0d
--- /dev/null
+++ b/workshop_app/static/workshop_app/js/overlay.js
@@ -0,0 +1,7 @@
+function overlay(course_no) {
+ el = document.getElementById("overlay");
+ course_id = document.getElementById("course_id");
+ el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
+
+ console.log(course_no);
+}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/base.html b/workshop_app/templates/workshop_app/base.html
new file mode 100644
index 0000000..cebab31
--- /dev/null
+++ b/workshop_app/templates/workshop_app/base.html
@@ -0,0 +1,52 @@
+
+
+
+
+
+ {% block title %}
+ HomePage
+ {% endblock %}
+
+
+
+
+
+
+
+
+
+
+
+ {% block extra %}
+ {% endblock %}
+
+
+
+ {% block header %}
+
+ {% endblock %}
+
+ {% block content %}
+ Base Template Content. Please override me
+ {% endblock %}
+
+
+
+
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/booking.html b/workshop_app/templates/workshop_app/booking.html
new file mode 100644
index 0000000..05ddbb6
--- /dev/null
+++ b/workshop_app/templates/workshop_app/booking.html
@@ -0,0 +1,22 @@
+{% extends './base.html' %}
+
+{% block title %}
+ Booking
+{% endblock %}
+
+{% block header %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/create_workshop.html b/workshop_app/templates/workshop_app/create_workshop.html
new file mode 100644
index 0000000..64727ad
--- /dev/null
+++ b/workshop_app/templates/workshop_app/create_workshop.html
@@ -0,0 +1,48 @@
+{% extends "./base.html" %}
+
+{% block title %}
+ Create Event
+{% endblock %}
+
+ {% block extra %}
+
+
+
+
+
+
+
+ {% endblock %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/edit_profile.html b/workshop_app/templates/workshop_app/edit_profile.html
new file mode 100644
index 0000000..d2c5655
--- /dev/null
+++ b/workshop_app/templates/workshop_app/edit_profile.html
@@ -0,0 +1,37 @@
+{% extends "./base.html" %}
+
+{% block title %}
+ Edit Profile
+{% endblock %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/index.html b/workshop_app/templates/workshop_app/index.html
new file mode 100644
index 0000000..7e163c8
--- /dev/null
+++ b/workshop_app/templates/workshop_app/index.html
@@ -0,0 +1,10 @@
+{% extends "./base.html" %}
+
+
+
+
+ {% block title %}
+ Welcome
+ {% endblock %}
+
+
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/login.html b/workshop_app/templates/workshop_app/login.html
new file mode 100644
index 0000000..fa505ab
--- /dev/null
+++ b/workshop_app/templates/workshop_app/login.html
@@ -0,0 +1,20 @@
+{% extends './base.html' %}
+
+ {% block title %}
+ Login
+ {% endblock %}
+
+ {% block content %}
+
+
+
+
+
+ {% endblock %}
diff --git a/workshop_app/templates/workshop_app/logout.html b/workshop_app/templates/workshop_app/logout.html
new file mode 100644
index 0000000..70a7862
--- /dev/null
+++ b/workshop_app/templates/workshop_app/logout.html
@@ -0,0 +1,16 @@
+{% extends './base.html' %}
+
+ {% block title %}
+ Logged out
+ {% endblock %}
+
+
+ {% block content %}
+
+
+
You have logged out successfully.
+
If you want to Login again please click here
+
+
+
+ {% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/manage.html b/workshop_app/templates/workshop_app/manage.html
new file mode 100644
index 0000000..a161ec2
--- /dev/null
+++ b/workshop_app/templates/workshop_app/manage.html
@@ -0,0 +1,35 @@
+{% extends './base.html' %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+
+
+ {% csrf_token %}
+ {% for w in workshop_details %}
+ {{ w.date }}
+ {{ w.start_time }}
+ {{ w.end_time }}
+ {{ w.workshop_creator }}
+ {{ w.workshop_title }}
+ {{ w.status }}
+ {% endfor %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/profile_updated.html b/workshop_app/templates/workshop_app/profile_updated.html
new file mode 100644
index 0000000..e9a0d54
--- /dev/null
+++ b/workshop_app/templates/workshop_app/profile_updated.html
@@ -0,0 +1,28 @@
+{% extends "./base.html" %}
+
+{% block title %}
+ Profile Changing
+{% endblock %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+{% dinesh akshen %}
+ Your Profile has changed {{ user.first_name }}
+{% endblock content %}
+
diff --git a/workshop_app/templates/workshop_app/register.html b/workshop_app/templates/workshop_app/register.html
new file mode 100644
index 0000000..fdb8bf8
--- /dev/null
+++ b/workshop_app/templates/workshop_app/register.html
@@ -0,0 +1,18 @@
+{% extends './base.html' %}
+
+ {% block title %}
+ Register
+ {% endblock %}
+
+ {% block content %}
+
+ {% endblock %}
diff --git a/workshop_app/templates/workshop_app/view_course_details.html b/workshop_app/templates/workshop_app/view_course_details.html
new file mode 100644
index 0000000..58004da
--- /dev/null
+++ b/workshop_app/templates/workshop_app/view_course_details.html
@@ -0,0 +1,26 @@
+{% extends './base.html' %}
+
+{% block title %}
+ View Course Details
+{% endblock %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/view_course_list.html b/workshop_app/templates/workshop_app/view_course_list.html
new file mode 100644
index 0000000..4348a0d
--- /dev/null
+++ b/workshop_app/templates/workshop_app/view_course_list.html
@@ -0,0 +1,101 @@
+{% extends './base.html' %}
+
+{% block title %}
+ View Course List
+{% endblock %}
+
+
+{% block header %}
+
+{% endblock %}
+
+{% block extra %}
+
+
+
+
+
+
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+ id |
+ Course Name |
+ Course Duration |
+
+
+
+ {% for course in courses %}
+
+
+ {{ forloop.counter }} |
+ {{ course.course_name }} |
+ {{ course.course_duration }} |
+ |
+
+
+
+
+
+
+
+
+ {{ course.course_description|safe }} |
+
+
+
+
+ |
+
+
+ {% endfor %}
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html
new file mode 100644
index 0000000..546af88
--- /dev/null
+++ b/workshop_app/templates/workshop_app/view_profile.html
@@ -0,0 +1,57 @@
+{% extends './base.html' %}
+
+{% block title %}
+ View Profile
+{% endblock %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+
+
+ {% csrf_token %}
+
+
+ |
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+
+
+
Edit Profile
+
+{% endblock %}
diff --git a/workshop_app/views.py b/workshop_app/views.py
index 54dc43d..2cb805e 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -1,10 +1,11 @@
from django.shortcuts import render, redirect
-from forms import UserRegistrationForm, UserLoginForm, ProfileForm
-from .models import Profile, User, has_profile
+from .forms import UserRegistrationForm, UserLoginForm, ProfileForm, CreateWorkshop
+from .models import Profile, User, has_profile, Workshop, Course
from django.template import RequestContext
from django.contrib.auth import login, logout, authenticate
from django.contrib.auth.decorators import login_required
from django.contrib import messages
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
@@ -23,7 +24,7 @@ def user_login(request):
if user.is_authenticated():
if user.groups.filter(name='instructor').count() > 0:
return redirect('/manage/')
- return redirect('/view_profile/')
+ return redirect('/book/')
if request.method == "POST":
form = UserLoginForm(request.POST)
@@ -32,7 +33,7 @@ def user_login(request):
login(request, user)
if user.groups.filter(name='instructor').count() > 0:
return redirect('/manage/')
- return redirect('/view_profile/')
+ return redirect('/book/')
else:
return render(request, 'workshop_app/login.html', {"form": form})
else:
@@ -53,12 +54,11 @@ def user_register(request):
username, password = form.save()
new_user = authenticate(username=username, password=password)
login(request, new_user)
- return redirect('/home')
+ return redirect('/view_profile/')
else:
return render(request, "workshop_app/register.html", {"form": form})
else:
form = UserRegistrationForm()
-
return render(request, "workshop_app/register.html", {"form": form})
@@ -71,18 +71,21 @@ def book(request):
else:
return redirect('/login/')
+@login_required
def manage(request):
user = request.user
if user.is_authenticated():
+ print user.id, user
if user.groups.filter(name='instructor').count() > 0:
- return render(request, "workshop_app/manage.html")
+ workshop_details = Workshop.objects.all()
+ return render(request, "workshop_app/manage.html", {"workshop_details": workshop_details})
return redirect('/book/')
else:
return redirect('/login/')
@login_required
def view_profile(request):
- """ view moderators and users profile """
+ """ view instructor and coordinator profile """
return render(request, "workshop_app/view_profile.html")
@login_required
@@ -125,6 +128,49 @@ def create_workshop(request):
user = request.user
if is_instructor(user):
- return render(request, 'workshop_app/create_workshop.html')
+ if request.method == 'POST':
+ form = CreateWorkshop(request.POST)
+ if form.is_valid():
+ form.save()
+ return redirect('/manage/')
+ else:
+ form = CreateWorkshop()
+ return render(request, 'workshop_app/create_workshop.html', {"form": form })
+ else:
+ return redirect('/book/')
+
+@login_required
+def view_course_list(request):
+ '''Gives the course details '''
+ user = request.user
+ if is_instructor(user):
+ course_list = Course.objects.all()
+ paginator = Paginator(course_list, 9) #Show upto 12 Courses per page
+
+ page = request.GET.get('page')
+ try:
+ courses = paginator.page(page)
+ except PageNotAnInteger:
+ #If page is not an integer, deliver first page.
+ courses = paginator.page(1)
+ except EmptyPage:
+ #If page is out of range(e.g 999999), deliver last page.
+ courses = paginator.page(paginator.num_pages)
+
+ return render(request, 'workshop_app/view_course_list.html', \
+ {'courses': courses})
+
else:
return redirect('/book/')
+
+@login_required
+def view_course_details(request):
+ '''Gives the course details '''
+
+ user = request.user
+ if is_instructor(user):
+
+ return redirect('/')
+
+ else:
+ return redirect('/book/')
\ No newline at end of file
--
cgit
From 2a0875890fd64e6b3b86a7e08378eea36bcf7ce4 Mon Sep 17 00:00:00 2001
From: Akshen Doke
Date: Tue, 7 Mar 2017 11:26:04 +0530
Subject: Phone Number added, email verification todo
---
workshop_app/forms.py | 24 ++++++++----
workshop_app/models.py | 14 ++++++-
workshop_app/templates/workshop_app/booking.html | 2 +-
.../templates/workshop_app/create_workshop.html | 2 +-
.../templates/workshop_app/edit_profile.html | 2 +-
workshop_app/templates/workshop_app/index.html | 2 +-
workshop_app/templates/workshop_app/login.html | 2 +-
workshop_app/templates/workshop_app/logout.html | 2 +-
workshop_app/templates/workshop_app/manage.html | 2 +-
.../templates/workshop_app/profile_updated.html | 5 +--
workshop_app/templates/workshop_app/register.html | 2 +-
.../workshop_app/view_course_details.html | 2 +-
.../templates/workshop_app/view_course_list.html | 2 +-
.../templates/workshop_app/view_profile.html | 6 ++-
workshop_app/views.py | 45 +++++++++++++++++-----
15 files changed, 81 insertions(+), 33 deletions(-)
(limited to 'workshop_app')
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
index 3cc0021..4264c20 100644
--- a/workshop_app/forms.py
+++ b/workshop_app/forms.py
@@ -27,12 +27,18 @@ class UserRegistrationForm(forms.Form):
(max_length=32, widget=forms.PasswordInput())
first_name = forms.CharField(max_length=32)
last_name = forms.CharField(max_length=32)
- institute = forms.CharField\
- (max_length=128, help_text='Institute/Organization')
- department = forms.CharField\
- (max_length=64, help_text='Department you work/study at')
- position = forms.ChoiceField\
- (help_text='If you are an instructor please mail us at python[at]fossee[dot]in', choices=position_choices)
+ phone_number = forms.RegexField(regex=r'^\+?1?\d{9,15}$',
+ error_message=("Phone number must be entered \
+ in the format: '+999999999'.\
+ Up to 15 digits allowed."))
+ institute = forms.CharField(max_length=128,
+ help_text='Institute/Organization')
+ department = forms.CharField(max_length=64, help_text='Department you work \
+ study at')
+ position = forms.ChoiceField(help_text='If you are an instructor please \
+ mail us at python[at]fossee[dot]in',
+ choices=position_choices
+ )
def clean_username(self):
u_name = self.cleaned_data["username"]
@@ -65,11 +71,13 @@ class UserRegistrationForm(forms.Form):
u_name = self.cleaned_data["username"]
u_name = u_name.lower()
pwd = self.cleaned_data["password"]
- email = self.cleaned_data['email']
+ email = self.cleaned_data["email"]
new_user = User.objects.create_user(u_name, email, pwd)
new_user.first_name = self.cleaned_data["first_name"]
new_user.last_name = self.cleaned_data["last_name"]
+
+
new_user.save()
cleaned_data = self.cleaned_data
@@ -77,7 +85,7 @@ class UserRegistrationForm(forms.Form):
new_profile.institute = cleaned_data["institute"]
new_profile.department = cleaned_data["department"]
new_profile.position = cleaned_data["position"]
-
+ new_profile.phone_number = cleaned_data["phone_number"]
new_profile.save()
return u_name, pwd
diff --git a/workshop_app/models.py b/workshop_app/models.py
index 9aceb57..8c146c0 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -1,6 +1,7 @@
#from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
+from django.core.validators import RegexValidator
position_choices = (
@@ -20,10 +21,21 @@ class Profile(models.Model):
user = models.OneToOneField(User)
institute = models.CharField(max_length=150)
department = models.CharField(max_length=150)
+ phone_number = models.CharField(
+ max_length=15,
+ validators=[RegexValidator(
+ regex=r'^\+?1?\d{9,15}$', message=(
+ "Phone number must be entered \
+ in the format: '+999999999'.\
+ Up to 15 digits allowed.")
+ )])
position = models.CharField(max_length=32, choices=position_choices)
def __str__(self):
- return u"{0} {1} | {2}".format(self.user.first_name, self.user.last_name, self.user.email)
+ return u"{0} {1} | {2} ".format(self.user.first_name,
+ self.user.last_name,
+ self.user.email
+ )
class Course(models.Model):
diff --git a/workshop_app/templates/workshop_app/booking.html b/workshop_app/templates/workshop_app/booking.html
index 05ddbb6..01cd609 100644
--- a/workshop_app/templates/workshop_app/booking.html
+++ b/workshop_app/templates/workshop_app/booking.html
@@ -1,4 +1,4 @@
-{% extends './base.html' %}
+{% extends 'workshop_app/base.html' %}
{% block title %}
Booking
diff --git a/workshop_app/templates/workshop_app/create_workshop.html b/workshop_app/templates/workshop_app/create_workshop.html
index 64727ad..93de011 100644
--- a/workshop_app/templates/workshop_app/create_workshop.html
+++ b/workshop_app/templates/workshop_app/create_workshop.html
@@ -1,4 +1,4 @@
-{% extends "./base.html" %}
+{% extends "workshop_app/base.html" %}
{% block title %}
Create Event
diff --git a/workshop_app/templates/workshop_app/edit_profile.html b/workshop_app/templates/workshop_app/edit_profile.html
index d2c5655..6d5698b 100644
--- a/workshop_app/templates/workshop_app/edit_profile.html
+++ b/workshop_app/templates/workshop_app/edit_profile.html
@@ -1,4 +1,4 @@
-{% extends "./base.html" %}
+{% extends "workshop_app/base.html" %}
{% block title %}
Edit Profile
diff --git a/workshop_app/templates/workshop_app/index.html b/workshop_app/templates/workshop_app/index.html
index 7e163c8..f0923bb 100644
--- a/workshop_app/templates/workshop_app/index.html
+++ b/workshop_app/templates/workshop_app/index.html
@@ -1,4 +1,4 @@
-{% extends "./base.html" %}
+{% extends "workshop_app/base.html" %}
diff --git a/workshop_app/templates/workshop_app/login.html b/workshop_app/templates/workshop_app/login.html
index fa505ab..cc733c7 100644
--- a/workshop_app/templates/workshop_app/login.html
+++ b/workshop_app/templates/workshop_app/login.html
@@ -1,4 +1,4 @@
-{% extends './base.html' %}
+{% extends 'workshop_app/base.html' %}
{% block title %}
Login
diff --git a/workshop_app/templates/workshop_app/logout.html b/workshop_app/templates/workshop_app/logout.html
index 70a7862..793bf5a 100644
--- a/workshop_app/templates/workshop_app/logout.html
+++ b/workshop_app/templates/workshop_app/logout.html
@@ -1,4 +1,4 @@
-{% extends './base.html' %}
+{% extends 'workshop_app/base.html' %}
{% block title %}
Logged out
diff --git a/workshop_app/templates/workshop_app/manage.html b/workshop_app/templates/workshop_app/manage.html
index a161ec2..4a399a1 100644
--- a/workshop_app/templates/workshop_app/manage.html
+++ b/workshop_app/templates/workshop_app/manage.html
@@ -1,4 +1,4 @@
-{% extends './base.html' %}
+{% extends 'workshop_app/base.html' %}
{% block header %}