diff options
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | workshop_app/admin.py | 5 | ||||
-rw-r--r-- | workshop_app/models.py | 17 | ||||
-rw-r--r-- | workshop_app/views.py | 23 | ||||
-rw-r--r-- | workshop_portal/settings.py | 2 | ||||
-rw-r--r-- | workshop_portal/urls.py | 5 |
6 files changed, 41 insertions, 13 deletions
diff --git a/requirements.txt b/requirements.txt index 286829d..73747b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ appdirs==1.4.0 Django==1.10.4 --e git+https://github.com/rodrigoamaral/django-fullcalendar.git@d116fcfc2093e57035932a9ea7c111d449fd7e4d#egg=django_fullcalendar packaging==16.8 pyparsing==2.1.10 +python-dateutil==2.6.0 six==1.10.0 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/') diff --git a/workshop_portal/settings.py b/workshop_portal/settings.py index 5681433..c4cb7e6 100644 --- a/workshop_portal/settings.py +++ b/workshop_portal/settings.py @@ -38,7 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'workshop_app', - 'fullcalendar', + ] MIDDLEWARE = [ diff --git a/workshop_portal/urls.py b/workshop_portal/urls.py index a25a634..78f09d7 100644 --- a/workshop_portal/urls.py +++ b/workshop_portal/urls.py @@ -18,6 +18,7 @@ from django.contrib import admin from workshop_app import views urlpatterns = [ + url(r'^$', views.index, name='index'), url(r'^admin/', admin.site.urls), url(r'^login/$', views.user_login), url(r'^logout/$', views.user_logout), @@ -25,5 +26,7 @@ urlpatterns = [ url(r'^book/$', views.book), url(r'^manage/$', views.manage), url(r'^view_profile/$', views.view_profile), - url(r'^edit_profile/$', views.edit_profile) + url(r'^edit_profile/$', views.edit_profile), + url(r'^create_workshop/$', views.create_workshop) + ] |