Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/pythonindia/wye
Conflicts:
	wye/templates/profile/index.html
  • Loading branch information
curioswati committed Nov 1, 2015
2 parents 409112f + e778c65 commit 69d63d2
Show file tree
Hide file tree
Showing 34 changed files with 776 additions and 189 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -83,3 +83,11 @@ node_modules/

#Sourcemap files
*.map

# VIM
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
12 changes: 12 additions & 0 deletions requirements/base.txt
Expand Up @@ -27,3 +27,15 @@ fake-factory==0.5.3
# Twitter Connect
# ---------------------------------------
twython==3.3.0

#AutoComplete
#------------------------------------------
django-autocomplete-light==2.2.10

# Image
# ----------------------------------------
Pillow==3.0.0

# Dateutils
#-----------------------------------------
python-dateutil==2.4.2
13 changes: 9 additions & 4 deletions settings/common.py
Expand Up @@ -14,6 +14,9 @@
import os
from os.path import join

ADMINS = (
('Vijay', 'vnbang2003@gmail.com'),
)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
APP_DIR = join(BASE_DIR, 'wye')

Expand Down Expand Up @@ -141,6 +144,10 @@
os.path.join(APP_DIR, 'static'),
)

# Media
MEDIA_URL = '/media/'

MEDIA_ROOT = os.path.join(APP_DIR, 'media')

REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS':
Expand All @@ -166,20 +173,18 @@
)

ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATIONA = True
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_SUBJECT_PREFIX = "[{}] ".format(SITE_VARIABLES['site_name'])
ACCOUNT_LOGOUT_ON_GET = True
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
ACCOUNT_SIGNUP_PASSWORD_VERIFICATION = False
ACCOUNT_SIGNUP_FORM_CLASS = 'wye.profiles.forms.SignupForm'

EMAIL_SUBJECT_PREFIX = ACCOUNT_EMAIL_SUBJECT_PREFIX

LOGIN_REDIRECT_URL = '/'

# E-Mail Settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.com'
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', ''),
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', ''),
Expand Down
42 changes: 0 additions & 42 deletions tests/functional/test_signup_flow.py

This file was deleted.

48 changes: 48 additions & 0 deletions wye/base/emailer_html.py
@@ -0,0 +1,48 @@
import threading

from django.conf import settings
from django.core.mail import EmailMultiAlternatives


def send_email_to_list(subject, body, users_list, text_body,
bcc_admins=True, bcc_managers=False):
bcc = []
if bcc_admins:
bcc += [email for name, email in settings.ADMINS] # @UnusedVariable

if bcc_managers:
bcc += [email for name, email in settings.MANAGERS] # @UnusedVariable
from_user = 'PythonExpress <noreply@pythonexpress.in>'
email = EmailMultiAlternatives(
subject, text_body, from_user, users_list, bcc)
email.attach_alternative(body, "text/html")
EmailThread(email).start()


def send_email_to_id(subject, body, email_id, text_body,
bcc_admins=True, bcc_managers=False):
bcc = []
if bcc_admins:
bcc += [email for name, email in settings.ADMINS] # @UnusedVariable

if bcc_managers:
bcc += [email for name, email in settings.MANAGERS] # @UnusedVariable

from_user = 'PythonExpress <noreply@pythonexpress.in>'
email = EmailMultiAlternatives(
subject, text_body, from_user, [email_id], bcc=bcc)
email.attach_alternative(body, "text/html")
EmailThread(email).start()


class EmailThread(threading.Thread):

def __init__(self, email):
self.email = email
threading.Thread.__init__(self)

def run(self):
try:
self.email.send()
except Exception as e:
print(e)
90 changes: 73 additions & 17 deletions wye/base/management/commands/sample_data.py
@@ -1,15 +1,19 @@
# -*- coding: utf-8 -*-
import random
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.core.management.base import BaseCommand
from django.db import transaction

from datetime import date
from faker import Faker

from wye.profiles.models import UserType, Profile
from wye.organisations.models import Organisation
from wye.profiles.models import UserType
from wye.regions.models import Location, State
from wye.workshops.models import WorkshopSections
from wye.workshops.models import WorkshopSections, Workshop
from wye.base.constants import WorkshopStatus, WorkshopLevel


NUMBER_OF_USERS = getattr(settings, "NUMBER_OF_USERS", 10)
Expand All @@ -20,37 +24,53 @@


class Command(BaseCommand):
help = "Creating Initial demo data for testing application"
fake = Faker()

@transaction.atomic
def handle(self, *args, **options):
self.fake.seed(4321)

print(' Updating domain to localhost:8000') # Update site url
self.stdout.write(' Updating domain to localhost:8000') # Update site url
site = Site.objects.get_current()
site.domain, site.name = 'localhost:8000', 'Local'
site.save()

print(' Creating Superuser')
self.stdout.write(' Creating Superuser')
email = 'admin@pythonexpress.in'
self.create_user(is_superuser=True, username='admin', email=email,
is_active=True, is_staff=True, first_name='Admin')
user = self.create_user(is_superuser=True, username='admin',
email=email, is_active=True, is_staff=True,
first_name='Admin')

print(' Creating sample users')
# User
self.stdout.write(' Creating sample users')
for i in range(NUMBER_OF_USERS):
self.create_user()

print(' Creating sample locations')
# Location
self.stdout.write(' Creating sample locations')
self.create_locations(counter=NUMBER_OF_LOCATIONS)

print(' Creating sample organisations')
# Organization
self.stdout.write(' Creating sample organisations')
self.create_organisations(counter=NUMBER_OF_ORGANISATIONS)

print(' Creating sample workshop sections')
self.create_workshop_sections(counter=NUMBER_OF_WORKSHOP_SECTIONS)
print(' Creating sample User Type sections')
# Workshop
self.stdout.write(' Creating sample workshop sections')
self.create_workshop_sections()

# User Type
self.stdout.write(' Creating User Types')
self.create_user_type(counter=NUMBER_OF_WORKSHOP_SECTIONS)

# Profile
self.stdout.write(' Creating Profile')
self.create_profile(user)

# Sample Workshops
self.stdout.write(' Creating Sample Workshop')
self.create_sample_workshops(user)

def create_user(self, counter=None, **kwargs):
params = {
"first_name": kwargs.get('first_name', self.fake.first_name()),
Expand All @@ -69,7 +89,7 @@ def create_user(self, counter=None, **kwargs):
user.set_password(password)
user.save()

print("SuperUser created with username: {username} and password: {password}".format(
self.stdout.write("SuperUser created with username: {username} and password: {password}".format(
username=params['username'], password=password)
)

Expand Down Expand Up @@ -111,7 +131,43 @@ def create_organisations(self, counter=None):
)
org.user.add(users[number])

def create_workshop_sections(self, counter=None):
for i in range(counter):
WorkshopSections.objects.update_or_create(
name=self.fake.sentence())
def create_workshop_sections(self):
sections = ["Python2", "Python3", "Django", "Flask", "Gaming"]

for section in sections:
self.stdout.write(' Creating %s' % section)
WorkshopSections.objects.create(name=section)

def create_profile(self, user):
django = WorkshopSections.objects.get(name='Django')
python3 = WorkshopSections.objects.get(name='Python3')
location = Location.objects.all()[0]
user_type = UserType.objects.get(slug='admin')
profile = Profile(
user=user,
mobile='8758885872',
location=location)
profile.usertype.add(user_type)
profile.interested_locations.add(location)
profile.interested_sections.add(django, python3)
profile.save()
return profile

def create_sample_workshops(self, user):
organisations = Organisation.objects.all()
locations = Location.objects.all()
sections = WorkshopSections.objects.all()

for i in range(50):
w = Workshop.objects.create(
no_of_participants=random.randrange(10, 100),
expected_date=date(2015, random.randrange(1, 12), random.randrange(1, 29)),
description=self.fake.text(),
requester=random.choice(organisations),
location=random.choice(locations),
workshop_level=WorkshopLevel.BEGINNER,
workshop_section=random.choice(sections),
status=WorkshopStatus.COMPLETED
)
w.presenter.add(user)
w.save()
Binary file added wye/media/images/newuser.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions wye/organisations/models.py
Expand Up @@ -16,13 +16,13 @@ class Organisation(AuditModel):
user = models.ManyToManyField(User, related_name='organisation_users')
active = models.BooleanField(default=True)

@property
def get_organisation_type(self):
return OrganisationType.CHOICES[self.organisation_type][1]

class Meta:
db_table = 'organisations'

def __str__(self):
return '{}-{}-{}'.format(self.name,
self.organisation_type, self.location)

@property
def get_organisation_user_list(self):
return self.user.all()

0 comments on commit 69d63d2

Please sign in to comment.