Skip to content

Commit

Permalink
Test case draft 3
Browse files Browse the repository at this point in the history
Test case draft 3
  • Loading branch information
Vijay committed Nov 17, 2017
1 parent fa874a9 commit 9ae5fc4
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 213 deletions.
2 changes: 1 addition & 1 deletion tests/functional/test_edit_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create_user_type(slug='tutor'):


def test_signup_college_poc_flow(base_url, browser, outbox):
tutor_type = create_user_type(slug='tutor')
create_user_type(slug='tutor')
user = create_user_verify_login(base_url, browser, outbox)
browser.fill('login', user.email)
browser.fill('password', '123123')
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_student_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime, timedelta
from tests import factories as f
from .. utils import create_user_verify_login
from wye.base.constants import WorkshopStatus, WorkshopLevel
from wye.base.constants import WorkshopStatus

import os
outbox_len = 0
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_student_profile_create(base_url, browser, outbox):
def test_student_register(base_url, browser, outbox):
"""
"""
student_poc = f.create_usertype(slug='student', display_name='Student')
f.create_usertype(slug='student', display_name='Student')
f.create_usertype(slug='tutor', display_name='tutor')
user = create_user_verify_login(base_url, browser, outbox)
user.first_name = 'First Name'
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_student_register(base_url, browser, outbox):
def test_student_email_certificate(base_url, browser, outbox):
"""
"""
student_poc = f.create_usertype(slug='student', display_name='Student')
f.create_usertype(slug='student', display_name='Student')
f.create_usertype(slug='tutor', display_name='tutor')
user = create_user_verify_login(base_url, browser, outbox)
user.first_name = 'First Name'
Expand Down
8 changes: 5 additions & 3 deletions wye/base/emailer_html.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import threading

from email.mime.application import MIMEApplication
# from django.conf import settings
from django.core.mail import EmailMultiAlternatives

Expand Down Expand Up @@ -45,8 +46,9 @@ def send_email_to_id(subject, body, email_id, text_body,
EmailThread(email).start()


def send_email_to_id_with_attachment(subject, body, email_id, text_body, filename,
bcc_admins=True, bcc_managers=False):
def send_email_to_id_with_attachment(
subject, body, email_id, text_body, filename,
bcc_admins=True, bcc_managers=False):
bcc = []

from_user = 'PythonExpress <noreply@pythonexpress.in>'
Expand Down
24 changes: 13 additions & 11 deletions wye/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@ def wrap(request, *args, **kwargs):
return f(request, *args, **kwargs)
return wrap


def get_username(email):
"""
Returns a UUID-based 'random' and unique username.
"""
Returns a UUID-based 'random' and unique username.
This is required data for user models with a username field.
"""
# uuid_str = str(uuid.uuid4())
username = email.split("@")[0]
# uuid_str = uuid_str[:30 - len(username)]
# print(username)
return username

This is required data for user models with a username field.
"""
uuid_str = str(uuid.uuid4())
username = email.split("@")[0]
# uuid_str = uuid_str[:30 - len(username)]
print(username)
return username

def add_user_create_reset_password_link(first_name, last_name, email, mobile, usertype):
def add_user_create_reset_password_link(
first_name, last_name, email, mobile, usertype):
user, created = User.objects.get_or_create(email=email)
if created:
user.first_name = first_name
Expand All @@ -76,4 +79,3 @@ def add_user_create_reset_password_link(first_name, last_name, email, mobile, us
profile.mobile = mobile
profile.save()
return user, created

40 changes: 5 additions & 35 deletions wye/profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@
import json
from dateutil.rrule import rrule, MONTHLY
from django.contrib.auth.models import User
# from django.http import HttpResponse
from django.db import models
from django.db.models.signals import post_save
from django.utils.functional import cached_property
from django.db.models import Avg
from slugify import slugify
# from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
# from matplotlib.figure import Figure
# from matplotlib.dates import DateFormatter
from wye.base.constants import WorkshopLevel, WorkshopStatus
from wye.regions.models import Location, State
from wye.workshops.models import (
Workshop, WorkshopSections,
WorkshopVoting, WorkshopFeedBack)
WorkshopVoting)
from wye.organisations.models import Organisation


Expand Down Expand Up @@ -45,7 +39,8 @@ class Profile(models.Model):
occupation = models.CharField(
null=True, blank=True, max_length=300, verbose_name=u"Occupation")
work_location = models.CharField(
null=True, blank=True, max_length=500, verbose_name=u"Organisaiton/Company")
null=True, blank=True, max_length=500,
verbose_name=u"Organisaiton/Company")
work_experience = models.FloatField(
null=True, blank=True, verbose_name=u"Work Experience(If Any)")
no_workshop = models.IntegerField(
Expand Down Expand Up @@ -103,12 +98,6 @@ def is_profile_filled(self):
return True
return False

# @cached_property
# def slug(self):
# return slugify(
# self.user.username,
# only_ascii=True)

@property
def get_workshop_details(self):
return Workshop.objects.filter(is_active=True).filter(
Expand Down Expand Up @@ -140,10 +129,6 @@ def get_total_no_of_participants(self):
self.get_workshop_details if (
x.status == WorkshopStatus.COMPLETED)])

# @property
# def get_last_workshop_date(self):
# pass

@property
def get_avg_workshop_rating(self):
workshops = self.get_workshop_details
Expand Down Expand Up @@ -174,23 +159,6 @@ def get_interested_locations(self):

@property
def get_graph_data(self):
# from django_pandas.io import read_frame
# qs = Workshop.objects.filter(
# presenter=self.user,
# status=WorkshopStatus.COMPLETED,
# is_active=True)
# # df = read_frame(qs)
# df = read_frame(qs,
# fieldnames=['workshop_section', 'expected_date'])
# print(df)
# fig = Figure()
# ax = fig.add_subplot(111)
# df.plot(ax=ax)
# canvas = FigureCanvas(fig)
# response = HttpResponse(content_type='image/png')
# canvas.print_png(response)
# return response

sections = WorkshopSections.objects.all()
workshops = Workshop.objects.filter(
presenter=self.user,
Expand Down Expand Up @@ -228,13 +196,15 @@ def get_graph_data(self):
return []
else:
return []

@property
def get_organisation_name(self):
return self.user.organisation_students.all()

@property
def get_student_workshop_attended_count(self):
return self.user.workshop_attended.count()

@property
def get_student_workshop_attended(self):
return self.user.workshop_attended.all()
Expand Down
44 changes: 1 addition & 43 deletions wye/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.contrib.auth.decorators import login_required
from wye.base.constants import WorkshopStatus
from wye.base.emailer_html import send_email_to_id, send_email_to_list
from wye.organisations.models import Organisation
# from wye.organisations.models import Organisation
from wye.profiles.models import Profile
from wye.workshops.models import Workshop

Expand All @@ -19,7 +19,6 @@

@login_required
def account_redirect(request):
print(request.user.username)
return redirect('/profile/{}/'.format(request.user.username))


Expand All @@ -40,47 +39,6 @@ def profile_view(request, slug):
"message": "Profile does not exist"})


# def user_dashboad(request):
# profile, created = Profile.objects.get_or_create(
# user__id=request.user.id)
# if not profile.is_profile_filled:
# return redirect('profiles:profile-edit', slug=request.user.username)
# workshop_all = Workshop.objects.filter(
# is_active=True).order_by('-expected_date')

# accept_workshops = workshop_all.filter(
# status=WorkshopStatus.ACCEPTED).filter(
# presenter__id__in=[request.user.id])
# requested_workshops = workshop_all.filter(
# status=WorkshopStatus.REQUESTED).filter(
# presenter__id__in=[request.user.id])
# requested_workshops = workshop_all.filter(
# status=WorkshopStatus.REQUESTED).filter(
# presenter__id__in=[request.user.id])

# organisation_all = Organisation.objects.all()
# context = {}
# for each_type in profile.get_user_type:
# if each_type == 'poc':
# context['is_college_poc'] = True
# context['users_organisation'] = organisation_all.filter(
# user=request.user)
# context['workshop_requested_under_poc'] = workshop_all.filter(
# requester__id__in=organisation_all.values_list(
# 'id', flat=True))
# context['workshops_accepted_under_poc'] = workshop_all.filter(
# status=WorkshopStatus.ACCEPTED,
# requester__id__in=organisation_all.values_list(
# 'id', flat=True))
# else:
# context['is_tutor'] = True
# context['workshop_requested_tutor'] = accept_workshops.filter(
# presenter=request.user)
# context['workshop_completed_tutor'] = \
# requested_workshops.filter(
# presenter=request.user)


class ProfileEditView(UpdateView):
model = Profile
template_name = 'profile/update.html'
Expand Down
2 changes: 0 additions & 2 deletions wye/workshops/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from wye.base.constants import (
WorkshopRatings,
WorkshopLevel,
WorkshopStatus,
FeedbackType,
YesNO)
from wye.base.widgets import CalendarWidget
Expand Down Expand Up @@ -133,7 +132,6 @@ def __init__(self, user, id, *args, **kwargs):
self.fields["comment"] = forms.CharField(widget=forms.Textarea)

def save(self, user, workshop_id):
print(dir(self))
data = {k: v for k, v in self.cleaned_data.items()}
WorkshopFeedBack.save_feedback(user, workshop_id, **data)

Expand Down
18 changes: 4 additions & 14 deletions wye/workshops/student_views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# from django.contrib.auth.decorators import login_required
# from django.views.decorators.csrf import csrf_exempt
# from django.core.urlresolvers import reverse, reverse_lazy
# from django.http import HttpResponseRedirect, JsonResponse
# from django.shortcuts import get_object_or_404
# from django.views import generic


import os
from io import BytesIO
from django.template import loader
Expand All @@ -16,9 +8,7 @@
from reportlab.lib.pagesizes import letter
from PyPDF2 import PdfFileReader, PdfFileWriter
from reportlab.lib.colors import black, red
# from wye.profiles.models import Profile
from wye.base.views import add_user_create_reset_password_link
# from wye.base.constants import WorkshopStatus
from wye.base.emailer_html import (
send_email_to_id, send_email_to_id_with_attachment)
from .forms import WorkshopCertificateForm
Expand Down Expand Up @@ -116,11 +106,11 @@ def register_students(request, pk):
email = WorkSheet.cell_value(row, 2)
mobile = WorkSheet.cell_value(row, 3)
workshop_name = workshop.workshop_section.name
institute = workshop.requester.name
# institute = workshop.requester.name
workshop_date = workshop.expected_date
presenters = workshop.presenter.all()
presenters_name = "\n".join(
["{} {}".format(p.first_name, p.last_name) for p in presenters])
# presenters = workshop.presenter.all()
# presenters_name = "\n".join(
# ["{} {}".format(p.first_name, p.last_name) for p in presenters])
student_user_type = UserType.objects.get(slug='student')
user, newly_created = add_user_create_reset_password_link(
first_name, last_name, email, mobile, student_user_type)
Expand Down

0 comments on commit 9ae5fc4

Please sign in to comment.