
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.models import User
from cronos.announcements.models import Id
	
if request.user.email[-21:] == 'notapplicablemail.com':
	mail = 'unset'
elif request.user.get_profile().webmail_username:
	mail = webmail_username + '@teilar.gr'
else:
	''
for item in Id.objects.filter(urlid__exact = request.user.get_profile().school):
	school = str(item.name)

@login_required
def user(request):
	return render_to_response('user.html', {
			'mail': mail,
		}, context_instance = RequestContext(request))

@login_required
def user_settings(request):
	return render_to_response('settings.html', {
			'school': school,
			'mail': mail,
		}, context_instance = RequestContext(request))


from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.models import User
from cronos.announcements.models import Id

def getmail(request):
	if request.user.email[-21:] == 'notapplicablemail.com':
		mail = 'unset'
	elif request.user.get_profile().webmail_username:
		mail = webmail_username + '@teilar.gr'
	else:
		''
	return mail

def getschool(request):
	for item in Id.objects.filter(urlid__exact = request.user.get_profile().school):
		school = str(item.name)
	return school

@login_required
def user(request):
	return render_to_response('user.html', {
			'mail': getmail(request),
		}, context_instance = RequestContext(request))

@login_required
def user_settings(request):
	return render_to_response('settings.html', {
			'school': getschool(request),
			'mail': getmail(request),
		}, context_instance = RequestContext(request))

Create functions getmail and getschool so they can be used in both sites user and settings
Create functions getmail and getschool so they can be used in both sites user and settings


  
  from django.contrib.auth.decorators import login_required
  from django.shortcuts import render_to_response
  from django.template import RequestContext
  from django.contrib.auth.models import User
  from cronos.announcements.models import Id
- 	
+ 
+ def getmail(request):
- if request.user.email[-21:] == 'notapplicablemail.com':
+ 	if request.user.email[-21:] == 'notapplicablemail.com':
- 	mail = 'unset'
+ 		mail = 'unset'
- elif request.user.get_profile().webmail_username:
+ 	elif request.user.get_profile().webmail_username:
- 	mail = webmail_username + '@teilar.gr'
+ 		mail = webmail_username + '@teilar.gr'
- else:
+ 	else:
- 	''
+ 		''
+ 	return mail
+ 
+ def getschool(request):
- for item in Id.objects.filter(urlid__exact = request.user.get_profile().school):
+ 	for item in Id.objects.filter(urlid__exact = request.user.get_profile().school):
- 	school = str(item.name)
+ 		school = str(item.name)
+ 	return school
  
  @login_required
  def user(request):
  	return render_to_response('user.html', {
- 			'mail': mail,
+ 			'mail': getmail(request),
  		}, context_instance = RequestContext(request))
  
  @login_required
  def user_settings(request):
  	return render_to_response('settings.html', {
- 			'school': school,
+ 			'school': getschool(request),
- 			'mail': mail,
+ 			'mail': getmail(request),
  		}, context_instance = RequestContext(request))
  
Create functions getmail and getschool so they can be used in both sites user and settings
## Code Before:

from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.models import User
from cronos.announcements.models import Id
	
if request.user.email[-21:] == 'notapplicablemail.com':
	mail = 'unset'
elif request.user.get_profile().webmail_username:
	mail = webmail_username + '@teilar.gr'
else:
	''
for item in Id.objects.filter(urlid__exact = request.user.get_profile().school):
	school = str(item.name)

@login_required
def user(request):
	return render_to_response('user.html', {
			'mail': mail,
		}, context_instance = RequestContext(request))

@login_required
def user_settings(request):
	return render_to_response('settings.html', {
			'school': school,
			'mail': mail,
		}, context_instance = RequestContext(request))

## Instruction:
Create functions getmail and getschool so they can be used in both sites user and settings
## Code After:

from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.models import User
from cronos.announcements.models import Id

def getmail(request):
	if request.user.email[-21:] == 'notapplicablemail.com':
		mail = 'unset'
	elif request.user.get_profile().webmail_username:
		mail = webmail_username + '@teilar.gr'
	else:
		''
	return mail

def getschool(request):
	for item in Id.objects.filter(urlid__exact = request.user.get_profile().school):
		school = str(item.name)
	return school

@login_required
def user(request):
	return render_to_response('user.html', {
			'mail': getmail(request),
		}, context_instance = RequestContext(request))

@login_required
def user_settings(request):
	return render_to_response('settings.html', {
			'school': getschool(request),
			'mail': getmail(request),
		}, context_instance = RequestContext(request))
