Ejemplo n.º 1
0
def main():

	flash("Getting user list...")

	users = Users()
	userList = users.getAllUsers()

	notificationsManager = NotificationsManager()

	for user in userList:
		
		flash("Looking for " + str(user.uuid) + ":" + user.username + " notifications...")
		
		notificationList = notificationsManager.getNotifications(userUuid = str(user.uuid), username = user.username, automaticallySetAsRead = False)


		if len(notificationList["notifications"]):

			recipientUuid = notificationList["notifications"][0]["recipientUuid"]

			messageText = ""
			
			for notification in notificationList["notifications"]:
				messageText += notification["messageSubject"] + " (" + notification["sendTimestamp"] + ")" + "\n"
				messageText += "----------------------------------------------------" + "\n"
				messageText += notification["messageText"] + "\n"
				messageText += "\n\n\n"

		
			messageSubject = "[BUILDING RULES] - Notifications report"
			flash("Sending report to " + str(user.uuid) + ":" + user.username + ":" + user.email)
			notificationsManager.sendNotificationByEmail(recipientUuid = recipientUuid, messageSubject = messageSubject, messageText = messageText)
Ejemplo n.º 2
0
	def registerTemporary(self, newUserUsername, newUserPassword, newUserEmail, newUserPersonName, newUserLevel = 10):
		checkData(locals())

		try:
			user = User(username = newUserUsername)
			user.retrieve()
			raise UsernameNotAvailableError("The username " + newUserUsername + " has been alredy assigned")

		except UserNotFoundError as e:
		
			if not(newUserUsername and newUserPassword and newUserEmail and newUserPersonName and newUserLevel):
				raise MissingInputDataError("Some input data are missing to register a new user")

			users = Users()
			freeUserSlot = users.getFirstFreeUserSlot()

			freeUserSlot.username = newUserUsername
			freeUserSlot.password = newUserPassword
			freeUserSlot.email = newUserEmail
			freeUserSlot.personName = newUserPersonName
			freeUserSlot.store()

			return freeUserSlot.getDict()