def save(self, *args, **kwargs): org_email_username = self.cleaned_data.get("org_email_username") orgsub_email_domain = self.cleaned_data.get("orgsub_email_domain") submitted_email = org_email_username + orgsub_email_domain try: prospective_user_check = ProspectiveUser.objects.get(email = submitted_email) except: prospective_user_check = False if not prospective_user_check: # prospective user doesn't exist, so create it prospective_user = ProspectiveUser(email = submitted_email) prospective_user.registration_code = make_random_string() prospective_user.last_invitation = datetime.datetime.now() org_sub = Organization.objects.get(email_domain__contains = orgsub_email_domain) prospective_user.org_sub = org_sub prospective_user.accepted = 0 send_invitation_to_member_via_register(submitted_email,prospective_user_check.registration_code) send_invitation_to_member_via_register(submitted_email,invite_url) prospective_user.save() return prospective_user else: # prospective user exists, but since rhizomeuser # doesn't exist (see cleaning method above) we resend offer prospective_user_check.registration_code = make_random_string() prospective_user_check.last_invitation = datetime.datetime.now() org_sub = Organization.objects.get(email_domain__contains = orgsub_email_domain) prospective_user_check.org_sub = org_sub prospective_user_check.accepted = 0 send_invitation_to_member_via_register(submitted_email,prospective_user_check.registration_code) prospective_user_check.save() return prospective_user_check
def save(self, *args, **kwargs): try: user_check = User.objects.get(email = self.cleaned_data.get("email_address")) except: user_check = False try: prospective_user_check = ProspectiveUser.objects.get(email = self.cleaned_data.get("email_address")) except: prospective_user_check = False if not user_check: if not prospective_user_check: prospective_user = ProspectiveUser(email = self.cleaned_data.get("email_address")) prospective_user.registration_code = make_random_string() prospective_user.last_invitation = datetime.datetime.now() prospective_user.org_sub = Organization.objects.get(id = self.cleaned_data.get("org")) admin = User.objects.get(id = self.cleaned_data.get("admin")) prospective_user.invite_admin = admin #so we can see who invited them prospective_user.accepted = 0 invite_url = "http://rhizome.org/welcome/orgsub/?email=%s®istration_code=%s" % \ (self.cleaned_data.get("email_address"),prospective_user.registration_code) send_invitation_to_prospective_user(self.cleaned_data.get("email_address"), admin.get_full_name(), self.cleaned_data.get("admin_email"),invite_url ) prospective_user.save() return "%s has been invited to join your organizational subscription" % self.cleaned_data.get("email_address") else: return "%s has already been invited to join your organizational subscription" % self.cleaned_data.get("email_address") else: return "%s has already joined Rhizome" % self.cleaned_data.get("email_address")
def save(self, commit=True): user = super(RhizomeUserCreationForm, self).save(commit=False) user.registration_code = make_random_string() user.is_active = 0 user.set_password(self.clean_password2()) user.email = self.cleaned_data.get('email') user.icon = "accounts/images/icons/rhizome_user_default.png" if commit: user.save() return user
def save(self, *args, **kwargs): org_email_username = self.cleaned_data.get("org_email_username") orgsub_email_domain = self.cleaned_data.get("orgsub_email_domain") submitted_email = org_email_username + orgsub_email_domain try: prospective_user_check = ProspectiveUser.objects.get( email=submitted_email) except: prospective_user_check = False if not prospective_user_check: # prospective user doesn't exist, so create it prospective_user = ProspectiveUser(email=submitted_email) prospective_user.registration_code = make_random_string() prospective_user.last_invitation = datetime.datetime.now() org_sub = Organization.objects.get( email_domain__contains=orgsub_email_domain) prospective_user.org_sub = org_sub prospective_user.accepted = 0 send_invitation_to_member_via_register( submitted_email, prospective_user_check.registration_code) send_invitation_to_member_via_register(submitted_email, invite_url) prospective_user.save() return prospective_user else: # prospective user exists, but since rhizomeuser # doesn't exist (see cleaning method above) we resend offer prospective_user_check.registration_code = make_random_string() prospective_user_check.last_invitation = datetime.datetime.now() org_sub = Organization.objects.get( email_domain__contains=orgsub_email_domain) prospective_user_check.org_sub = org_sub prospective_user_check.accepted = 0 send_invitation_to_member_via_register( submitted_email, prospective_user_check.registration_code) prospective_user_check.save() return prospective_user_check
def save(self, *args, **kwargs): try: user_check = User.objects.get( email=self.cleaned_data.get("email_address")) except: user_check = False try: prospective_user_check = ProspectiveUser.objects.get( email=self.cleaned_data.get("email_address")) except: prospective_user_check = False if not user_check: if not prospective_user_check: prospective_user = ProspectiveUser( email=self.cleaned_data.get("email_address")) prospective_user.registration_code = make_random_string() prospective_user.last_invitation = datetime.datetime.now() prospective_user.org_sub = Organization.objects.get( id=self.cleaned_data.get("org")) admin = User.objects.get(id=self.cleaned_data.get("admin")) prospective_user.invite_admin = admin #so we can see who invited them prospective_user.accepted = 0 invite_url = "http://rhizome.org/welcome/orgsub/?email=%s®istration_code=%s" % \ (self.cleaned_data.get("email_address"),prospective_user.registration_code) send_invitation_to_prospective_user( self.cleaned_data.get("email_address"), admin.get_full_name(), self.cleaned_data.get("admin_email"), invite_url) prospective_user.save() return "%s has been invited to join your organizational subscription" % self.cleaned_data.get( "email_address") else: return "%s has already been invited to join your organizational subscription" % self.cleaned_data.get( "email_address") else: return "%s has already joined Rhizome" % self.cleaned_data.get( "email_address")