def view_profile(request): is_young=is_young_check(request) is_principal=is_principal_check(request) try: users = YoungInvestigator.objects.get(user_id__exact=request.user.id) keywords=Keyword.objects.filter(young=users) offers=[] except: users = PrincipalInvestigator.objects.get(user_id__exact=request.user.id) keywords=Keyword.objects.filter(principal=users) a=datetime.now() offers=Offer.objects.filter(principal=users, deadline__gt=a) if request.method=='POST': if(is_young): users_form=YoungInvestigatorForm(request.POST) else: users_form=PrincipalInvestigatorForm(request.POST) keywords_form = KeywordsForm(request.POST) if (keywords_form.is_valid()): if(is_young): Keyword.objects.create(young=users,word=keywords_form.cleaned_data['word']) elif(is_principal): Keyword.objects.create(principal=users,word=keywords_form.cleaned_data['word']) if users_form.is_valid(): if is_young: # 'telephone','title','specialty','research_field','research_speciality','h_index','country','city', # 'facebook_link','twitter_link','linkedIn_link','principal_text','other_text' users.telephone=users_form.cleaned_data['telephone'] users.title=users_form.cleaned_data['title'] users.specialty=users_form.cleaned_data['specialty'] users.research_field=users_form.cleaned_data['research_field'] users.research_speciality=users_form.cleaned_data['research_speciality'] users.h_index=users_form.cleaned_data['h_index'] users.country=users_form.cleaned_data['country'] users.city=users_form.cleaned_data['city'] users.facebook_link=users_form.cleaned_data['facebook_link'] users.twitter_link=users_form.cleaned_data['twitter_link'] users.linkedIn_link=users_form.cleaned_data['linkedIn_link'] users.principal_text=users_form.cleaned_data['principal_text'] users.other_text=users_form.cleaned_data['other_text'] users.save() elif(is_principal): # 'telephone','research_field','research_speciality','h_index','country','city','facebook_link', # 'twitter_link','linkedIn_link','principal_text','other_text','number_of_authorisating' # ,'interested_in_premium' users.telephone=users_form.cleaned_data['telephone'] users.research_field=users_form.cleaned_data['research_field'] users.research_speciality=users_form.cleaned_data['research_speciality'] users.h_index=users_form.cleaned_data['h_index'] users.country=users_form.cleaned_data['country'] users.city=users_form.cleaned_data['city'] users.facebook_link=users_form.cleaned_data['facebook_link'] users.twitter_link=users_form.cleaned_data['twitter_link'] users.linkedIn_link=users_form.cleaned_data['linkedIn_link'] users.principal_text=users_form.cleaned_data['principal_text'] users.other_text=users_form.cleaned_data['other_text'] users.number_of_authorisating=users_form.cleaned_data['number_of_authorisating'] users.interested_in_premium=users_form.cleaned_data['interested_in_premium'] users.save() keywords_form = KeywordsForm() if(is_young): users_form=YoungInvestigatorForm(instance=users) else: users_form=PrincipalInvestigatorForm(instance=users) return render_to_response('users/profile.html', {'users':users,'is_young':is_young,'is_principal':is_principal, 'keywords_form':keywords_form,'keywords':keywords,'users_form':users_form, 'offers':offers,}, context_instance = RequestContext(request))
def view_profile(request): is_young = is_young_check(request) is_principal = is_principal_check(request) try: users = YoungInvestigator.objects.get(user_id__exact=request.user.id) keywords = Keyword.objects.filter(young=users) offers = [] except: users = PrincipalInvestigator.objects.get( user_id__exact=request.user.id) keywords = Keyword.objects.filter(principal=users) a = datetime.now() offers = Offer.objects.filter(principal=users, deadline__gt=a) if request.method == 'POST': if (is_young): users_form = YoungInvestigatorForm(request.POST) else: users_form = PrincipalInvestigatorForm(request.POST) keywords_form = KeywordsForm(request.POST) if (keywords_form.is_valid()): if (is_young): Keyword.objects.create(young=users, word=keywords_form.cleaned_data['word']) elif (is_principal): Keyword.objects.create(principal=users, word=keywords_form.cleaned_data['word']) if users_form.is_valid(): if is_young: # 'telephone','title','specialty','research_field','research_speciality','h_index','country','city', # 'facebook_link','twitter_link','linkedIn_link','principal_text','other_text' users.telephone = users_form.cleaned_data['telephone'] users.title = users_form.cleaned_data['title'] users.specialty = users_form.cleaned_data['specialty'] users.research_field = users_form.cleaned_data[ 'research_field'] users.research_speciality = users_form.cleaned_data[ 'research_speciality'] users.h_index = users_form.cleaned_data['h_index'] users.country = users_form.cleaned_data['country'] users.city = users_form.cleaned_data['city'] users.facebook_link = users_form.cleaned_data['facebook_link'] users.twitter_link = users_form.cleaned_data['twitter_link'] users.linkedIn_link = users_form.cleaned_data['linkedIn_link'] users.principal_text = users_form.cleaned_data[ 'principal_text'] users.other_text = users_form.cleaned_data['other_text'] users.save() elif (is_principal): # 'telephone','research_field','research_speciality','h_index','country','city','facebook_link', # 'twitter_link','linkedIn_link','principal_text','other_text','number_of_authorisating' # ,'interested_in_premium' users.telephone = users_form.cleaned_data['telephone'] users.research_field = users_form.cleaned_data[ 'research_field'] users.research_speciality = users_form.cleaned_data[ 'research_speciality'] users.h_index = users_form.cleaned_data['h_index'] users.country = users_form.cleaned_data['country'] users.city = users_form.cleaned_data['city'] users.facebook_link = users_form.cleaned_data['facebook_link'] users.twitter_link = users_form.cleaned_data['twitter_link'] users.linkedIn_link = users_form.cleaned_data['linkedIn_link'] users.principal_text = users_form.cleaned_data[ 'principal_text'] users.other_text = users_form.cleaned_data['other_text'] users.number_of_authorisating = users_form.cleaned_data[ 'number_of_authorisating'] users.interested_in_premium = users_form.cleaned_data[ 'interested_in_premium'] users.save() keywords_form = KeywordsForm() if (is_young): users_form = YoungInvestigatorForm(instance=users) else: users_form = PrincipalInvestigatorForm(instance=users) return render_to_response('users/profile.html', { 'users': users, 'is_young': is_young, 'is_principal': is_principal, 'keywords_form': keywords_form, 'keywords': keywords, 'users_form': users_form, 'offers': offers, }, context_instance=RequestContext(request))
def registration_young_inv(request): if request.method=='POST': userForm = UserForm(request.POST) formulario = YoungInvestigatorForm(request.POST) if userForm.is_valid(): if (formulario.is_valid() and userForm.is_valid()): first_name=userForm.cleaned_data['first_name'] last_name=userForm.cleaned_data['last_name'] username=userForm.cleaned_data['username'] email=userForm.cleaned_data['email'] telephone=formulario.cleaned_data['telephone'] # title = formulario.cleaned_data['title'] # specialty = formulario.cleaned_data['specialty'] # research_field=formulario.cleaned_data['research_field'] # research_speciality=formulario.cleaned_data['research_speciality'] # h_index=formulario.cleaned_data['h_index'] # country=formulario.cleaned_data['country'] # city=formulario.cleaned_data['city'] # facebook_link=formulario.cleaned_data['facebook_link'] # twitter_link=formulario.cleaned_data['twitter_link'] # linkedIn_link=formulario.cleaned_data['linkedIn_link'] # principal_text=formulario.cleaned_data['principal_text'] # other_text=formulario.cleaned_data['specialty'] # autogenerado token= ##Creacion de usuario user1 = User(username=userForm.cleaned_data['username'], first_name=userForm.cleaned_data['first_name'], last_name=userForm.cleaned_data['last_name'], email=userForm.cleaned_data['email'], is_active=0,) #Le asignamos la clave encriptada user1.set_password(userForm.cleaned_data['password']) user1.save() ##Activation Link activation_key = ''.join(random.choice('123456789abcdefghijklmnopqrstuvwxyz') for _ in range(20)) ctx_dict = {'activation_key': activation_key, 'first_name': first_name, 'last_name': last_name, 'username': username, 'email': email, 'telephone': telephone,} ##Editor young=YoungInvestigator.objects.create( user = user1, telephone =formulario.cleaned_data['telephone'] , title = formulario.cleaned_data['title'], specialty = formulario.cleaned_data['specialty'], research_field=formulario.cleaned_data['research_field'], research_speciality=formulario.cleaned_data['research_speciality'], h_index=formulario.cleaned_data['h_index'], country=formulario.cleaned_data['country'], city=formulario.cleaned_data['city'], facebook_link=formulario.cleaned_data['facebook_link'], twitter_link=formulario.cleaned_data['twitter_link'], linkedIn_link=formulario.cleaned_data['linkedIn_link'], principal_text=formulario.cleaned_data['principal_text'], other_text=formulario.cleaned_data['other_text'], token=activation_key,) ##envio correo al editor mail_text = striptags('') from_email= '*****@*****.**' html_content = render_to_string('users/activation_email_for_user.txt',ctx_dict) msg1 = EmailMultiAlternatives("User registration request for ScienceWeb", mail_text, from_email, [email]) msg1.attach_alternative(html_content, "text/html") msg1.send() return render_to_response('users/registration_complete.html') else: formulario = YoungInvestigatorForm() userForm = UserForm() return render_to_response('users/registration_form.html', {'formulario':formulario,'userForm':userForm,'urlRequest':"/users/register_yi"}, context_instance = RequestContext(request))
def registration_young_inv(request): if request.method == 'POST': userForm = UserForm(request.POST) formulario = YoungInvestigatorForm(request.POST) if userForm.is_valid(): if (formulario.is_valid() and userForm.is_valid()): first_name = userForm.cleaned_data['first_name'] last_name = userForm.cleaned_data['last_name'] username = userForm.cleaned_data['username'] email = userForm.cleaned_data['email'] telephone = formulario.cleaned_data['telephone'] # title = formulario.cleaned_data['title'] # specialty = formulario.cleaned_data['specialty'] # research_field=formulario.cleaned_data['research_field'] # research_speciality=formulario.cleaned_data['research_speciality'] # h_index=formulario.cleaned_data['h_index'] # country=formulario.cleaned_data['country'] # city=formulario.cleaned_data['city'] # facebook_link=formulario.cleaned_data['facebook_link'] # twitter_link=formulario.cleaned_data['twitter_link'] # linkedIn_link=formulario.cleaned_data['linkedIn_link'] # principal_text=formulario.cleaned_data['principal_text'] # other_text=formulario.cleaned_data['specialty'] # autogenerado token= ##Creacion de usuario user1 = User( username=userForm.cleaned_data['username'], first_name=userForm.cleaned_data['first_name'], last_name=userForm.cleaned_data['last_name'], email=userForm.cleaned_data['email'], is_active=0, ) #Le asignamos la clave encriptada user1.set_password(userForm.cleaned_data['password']) user1.save() ##Activation Link activation_key = ''.join( random.choice('123456789abcdefghijklmnopqrstuvwxyz') for _ in range(20)) ctx_dict = { 'activation_key': activation_key, 'first_name': first_name, 'last_name': last_name, 'username': username, 'email': email, 'telephone': telephone, } ##Editor young = YoungInvestigator.objects.create( user=user1, telephone=formulario.cleaned_data['telephone'], title=formulario.cleaned_data['title'], specialty=formulario.cleaned_data['specialty'], research_field=formulario.cleaned_data['research_field'], research_speciality=formulario. cleaned_data['research_speciality'], h_index=formulario.cleaned_data['h_index'], country=formulario.cleaned_data['country'], city=formulario.cleaned_data['city'], facebook_link=formulario.cleaned_data['facebook_link'], twitter_link=formulario.cleaned_data['twitter_link'], linkedIn_link=formulario.cleaned_data['linkedIn_link'], principal_text=formulario.cleaned_data['principal_text'], other_text=formulario.cleaned_data['other_text'], token=activation_key, ) ##envio correo al editor mail_text = striptags('') from_email = '*****@*****.**' html_content = render_to_string( 'users/activation_email_for_user.txt', ctx_dict) msg1 = EmailMultiAlternatives( "User registration request for ScienceWeb", mail_text, from_email, [email]) msg1.attach_alternative(html_content, "text/html") msg1.send() return render_to_response('users/registration_complete.html') else: formulario = YoungInvestigatorForm() userForm = UserForm() return render_to_response('users/registration_form.html', { 'formulario': formulario, 'userForm': userForm, 'urlRequest': "/users/register_yi" }, context_instance=RequestContext(request))