Created
June 27, 2012 02:52
-
-
Save renatooliveira/3001022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staff_member_required | |
def carregar_alunos(request): | |
if request.method == "POST": | |
if 'listalunos' in request.FILES: | |
f = request.FILES['listalunos'] | |
chunk = f.chunks().next() | |
for line in chunk.split('\n'): | |
email = line | |
login = email.split('@')[0] | |
password = generate_key() | |
if email.__len__() > 0: | |
send_mail('Avaliacao dos professores', 'Sua senha e: ' + password, 'dacinufpe@gmail.com', | |
[email], fail_silently=False) | |
try: | |
user = User.objects.create_user(login, email, password) | |
aluno = Aluno.objects.get_or_create(user=user) | |
except: | |
user = User.objects.create_user(login, email, password) | |
aluno = Aluno(user=user) | |
aluno.save() | |
return render_to_response('cadastrarAluno.html', locals(), context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment