Exemplo n.º 1
0
Arquivo: admin.py Projeto: masyl/wrook
	def get(self):
		self.onRequest(isSetup=True)
		wrookAppConfig = app.getWrookAppConfig(flushCache=True, createIfNone=True)
		form = SetupForm(instance=wrookAppConfig)
		self.Model.update({
			"form": form
			})
		self.render("setup.html")
Exemplo n.º 2
0
Arquivo: admin.py Projeto: masyl/wrook
	def post(self):
		self.onRequest(isSetup=True)
		wrookAppConfig = app.getWrookAppConfig(flushCache=True, createIfNone=True)

		form = SetupForm(data=self.request.POST, instance=wrookAppConfig)
		if form.is_valid():
			# Save the form, and redirect to the view page
			entity = form.save(commit=False)
			entity.SetupComplete = True
			entity.put()
			wrookAppConfig = app.getWrookAppConfig(flushCache=True, createIfNone=True)
			self.redirect("/admin/setup/complete")
		else:
			self.Model.update({
				"form": form
				})
			self.render("setup.html")
Exemplo n.º 3
0
Arquivo: books.py Projeto: wrook/wrook
 def getCover(self):
     if self.Cover:
         return self.Cover
     else:
         appConfig = app.getWrookAppConfig()
         if appConfig:
             return appConfig.DefaultCover
     return None
Exemplo n.º 4
0
	def post(self, key): #TODO: Refactor -  This handler should be moved to the membership module and actuel business logic should be in separate methods
		import app
		self.onRequest()
		if key: invite = Invite.get(key)
		else: invite = None
		username = self.request.get("Username").strip().lower() #TODO: Stripping and lowercasing should also be in the class logic
		email = self.request.get("Email").strip().lower() #TODO: Stripping and lowercasing should also be in the class logic
		firstname = self.request.get("Firstname").strip()
		lastname = self.request.get("Lastname").strip()
		gender = self.request.get("Gender")
		preferedLanguage = self.request.get("PreferedLanguage")
		isValid = True
		if (firstname == "" or lastname == "" or email == "" or username == ""):
			isValid = False
			error = _("Username, email, firstname and lastname are madatory!")
		elif (not username.isalnum()):
			isValid = False
			error = _("Sorry, the username can only contain letters and numbers.")
		elif (getMemberFromCredentials(email)): #TODO: Refactor -  This constraint should be built into the Member entity
			isValid = False
			error = _("This email address is already used by another member")
		elif (getMemberFromCredentials(username)): #TODO: Refactor -  This constraint should be built into the Member entity
			isValid = False
			error = _("This username address is already used by another member")

		# If no admin is setup and the email matches the one in the config. Gite admin rights
		admin = app.getWrookAdmin()
		if not admin:
			isNewAdmin = True
			wrookAppConfig = app.getWrookAppConfig(flushCache=True)
			if (wrookAppConfig.SiteAdminEmail.lower() != email):
				isValid = False
				error = _("The email address provided does not match the site administrator email provided during the initial setup.")

		if (not isValid):
			self.Model.update({
				'username': username,
				'email': email,
				'firstname': firstname,
				'lastname': lastname,
				'gender': gender,
				'preferedLanguage': preferedLanguage,
				'error': error
				})
			self.render2("views/join.html")
		else:
			member = Member(
				Username = username,
				Email = email,
				Firstname = firstname,
				Lastname = lastname,
				Gender = gender,
				PreferedLanguage = preferedLanguage,
				)
			member.Firstname = firstname
			member.Lastname = lastname

			if isNewAdmin:
				member.isAdmin = True
				member.save() # attribute assignation is repeated for them to be catched by the searchable model
				member.setPassword(email, self.AppConfig.EncryptionKey)
				self.redirect("/Login")
			else:
				member.save() # attribute assignation is repeated for them to be catched by the searchable model
				member.resetPassword(self.AppConfig.EncryptionKey)
				self.redirect("/ResetPassword/%s" % member.key())