def editInstitute(request): mlogger.debug("Editing the institute data") if request.method == "GET" : admin = request.institute.admin profile = admin.get_profile() initial_data = {'adminname':profile.fullname, 'adminemail':admin.email, } form = IRegForm(request.institute.id,initial=initial_data,instance=request.institute) elif request.method == "POST" : admin = request.institute.admin profile = admin.get_profile() form = IRegForm(request.institute.id,request.POST,instance=request.institute) if form.is_valid() : create_message(request,"Update the institute settings successfully ................") profile.fullname = form.cleaned_data['adminname'] profile.user.username = form.cleaned_data['adminemail'].replace("@","_").replace(".","_") profile.save() admin.email = form.cleaned_data['adminemail'] admin.save() inst = form.save(commit=False) inst.save() return render_to_response("institution/editinstitute.html",{'form':form},RequestContext(request))
def registerInstitution(request): ''' method which display and registration an institution''' #for now display the question mlogger.debug("Registering an institute................") if request.method == 'GET': #display form form = IRegForm(0) else: form = IRegForm(0,request.POST,request.FILES) if form.is_valid() : inst = form.save(commit=False) inst.admin = createAdmin(form.cleaned_data['adminemail'],form.cleaned_data['password1'],form.cleaned_data['adminname']) inst.save() inst.admin.get_profile().institutes.add(inst) mlogger.debug("Creating an institution %s" %(inst.name,)) #associate institute logo as avatar of admin createAdminAvatar(request,inst.admin,'logo') fullactivationurl = inst.admin.get_profile().get_full_activation_url(inst) deliverEmail('newinstitute_subject.html','newinstitute_message.html',{'institute':inst,'fullactivationurl':fullactivationurl,'user':inst.admin,'password':form.cleaned_data['password1']},inst.admin.email) #Tell ALumclub admin about new registration emails = getALumClubAdminUrls() deliverEmail('tell_new_institute_registration.html','tell_new_institute_registration_message.html',{'institute':inst,'fullactivationurl':fullactivationurl,'user':inst.admin,'password':form.cleaned_data['password1']},emails) #redirect return HttpResponseRedirect("http://%s%s/"%(inst.subdomain,settings.DOMAIN_NAME)) else : pass return render_to_response("institution/register.html",{'form':form},RequestContext(request))