Beispiel #1
0
	def update(self, id):
		contact = model.Contact.query().get(id)
		if contact == None:
			error = Error()
			error.id = 1
			error.message = "Contact with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")		

		if "denumire_con" in request.params:
			contact.denumire_con = request.params["denumire_con"]
		
		if "persoana_con" in request.params:
			contact.persoana_con = request.params["persoana_con"]

		if "email_con" in request.params:
			contact.email_con = request.params["email_con"]

		if "phone_con" in request.params:
			contact.phone_con = request.params["phone_con"]

		if "adresa_con" in request.params:
			contact.adresa_con = request.params["adresa_con"]

		if "tip_con" in request.params:
			contact.tip_con = request.params["tip_con"]

		if "addedby_con" in request.params:
			contact.addedby_con = request.params["addedby_con"]

		if "visible_con" in request.params:
			contact.visible_con = request.params["visible_con"]

		model.meta.Session.commit()
		return render("users/opstatus.mako")
Beispiel #2
0
	def update(self, id):
		meeting = model.Meeting.query().get(id)
		if meeting is None:
			error = Error()
			error.id = 1
			error.message = "Meeting with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")

		if "subject_met" in request.params:
			meeting.subject_met = request.params["subject_met"]

		if "location_met" in request.params:
			meeting.location_met = request.params["location_met"]

		if "participants_met" in request.params:
			meeting.participants_met = request.params["participants_met"]

		if "owner_met" in request.params:
			meeting.owner_met = request.params["owner_met"]
		
		if "start_met" in request.params:
			meeting.start_met = datetime.strptime(request.params["start_met"], "%Y/%m/%d")
		
		if "end_met" in request.params:
			meeting.end_met = datetime.strptime(request.params["end_met"], "%Y/%m/%d")
		
		if "notes_met" in request.params:
			meeting.notes_met = request.params["notes_met"]
			
		model.meta.Session.commit()
		return render("users/opstatus.mako")
Beispiel #3
0
	def create(self):
		"""POST /users: Create a new item."""
		if "email_usr" not in request.params or "password_usr" not in request.params:
			error = Error()
			error.id = 4
			error.message = "Missing required data. At least username/password must be supplied"
			c.error = error
			return render("users/error.mako")
		
		email = request.params['email_usr']
		result = model.User.query().filter(User.email_usr == email).all()
		if len(result) > 0:
			error = Error()
			error.id = 5
			error.message = "Username already in use"
			c.error = error
			return render("users/error.mako")
		
		password = request.params["password_usr"]
		name = request.params["name_usr"]
		status = 2 if "status_usr" not in request.params else request.params["status_usr"]
		address = request.params["address_usr"] if "address_usr" in request.params else None
		phone = request.params["phone_usr"] if "phone_usr" in request.params else None
		teamid = request.params["teamid_usr"] if "teamid_usr" in request.params else None
		managerid = request.params["managerid_usr"] if "managerid_usr" in request.params else None
		salary = request.params["salary_usr"] if "salary_usr" in request.params else None
		notes = request.params["notes_usr"] if "notes_usr" in request.params else None
		
		user = model.User(email, password, name, status, address, phone, salary, teamid, managerid, notes)
		model.meta.Session.add(user)
		model.meta.Session.commit()		
		return render("users/opstatus.mako")
Beispiel #4
0
    def update(self, id):
        document = model.Document.query().get(id)
        if document is None:
            error = Error()
            error.id = 2
            error.message = "The document with id %s does not exist" % id
            c.error = error
            return render("users/error.mako")
        permanent_store = "%s/%s/" % (self.document_store, document.idprj_doc)
        old_file_location = "%s/%s/%s" % (self.document_store, document.idprj_doc, document.file_doc)

        if "name_doc" in request.params:
            document.name_doc = request.params["name"]

        if "idprj_doc" in request.params:
            document.idprj_doc = request.params["project_id"]

        if "file_doc" in request.params:
            # overwrite old file
            os.remove(old_file_location)
            myfile = request.POST["file_doc"]
            filename = myfile.filename.lstrip(os.sep)
            permanent_file = open(os.path.join(permanent_store, filename), "w")

            shutil.copyfileobj(myfile.file, permanent_file)
            myfile.file.close()
            permanent_file.close()
            document.file_doc = filename

        model.meta.Session.commit()
        return render("users/opstatus.mako")
Beispiel #5
0
	def index(self):
		c.users = model.User.query().all()
		if c.users is None or len(c.users) == 0:
			error = Error()
			error.id = 1
			error.message = "No users in the system"
			c.error = error
			return render("users/error.mako")
		return render("users/index.mako")
Beispiel #6
0
	def show(self, id):
		result = model.Project.query().get(id)
		if result is None: #nothing in db
			error = Error()
			error.id = 2
			error.message = "The project with the id %s does not exist" % id
			c.error = error
			return render("users/error.mako")		
		c.projects = [result]
		return render('projects/index.mako')
Beispiel #7
0
	def show(self, id):
		meeting = model.Meeting.query().get(id)
		if meeting is None:
			error = Error()
			error.id = 1
			error.message = "Meeting with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")
		c.meetings = [meeting]
		return render("meetings/index.mako")
Beispiel #8
0
	def index(self):
		meetings = model.Meeting.query().all()
		if len(meetings) == 0:
			error = Error()
			error.id = 1
			error.message = "No data in the system."
			c.error = error
			return render("users/error.mako")
		c.meetings = meetings
		return render("meetings/index.mako")
Beispiel #9
0
	def teams_for_manager(self, id):
		teams = model.Team.query().filter(Team.managerid_tms == id).all()
		if len(teams) == 0:
			error = Error()
			error.id = 5
			error.message = "No teams for manager id %s." % id
			c.error = error
			return render("users/error.mako")
		c.teams = teams
		return render("teams/index.mako")
Beispiel #10
0
 def show(self, id):
     result = model.Document.query().get(id)
     if result is None:
         error = Error()
         error.id = 2
         error.message = "The document with id %s does not exist" % id
         c.error = error
         return render("users/error.mako")
     c.documents = [result]
     return render("documents/index.mako")
Beispiel #11
0
	def show(self, id):
		task = model.Task.query().get(id)
		if task is None:
			error = Error()
			error.id = 1
			error.message = "Task with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")
		c.tasks = [task]
		return render("tasks/index.mako")
Beispiel #12
0
	def index(self):
		tasks = model.Task.query().all()
		if len(tasks) == 0:
			error = Error()
			error.id = 1
			error.message = "No data in the system."
			c.error = error
			return render("users/error.mako")
		c.tasks = tasks
		return render("tasks/index.mako")
Beispiel #13
0
	def tasks_for_user(self, id):
		tasks = model.Task.query().filter(or_(Task.added_by_tsk == id, Task.assignedto_tsk == id)).all()
		if len(tasks) == 0:
			error = Error()
			error.id = 1
			error.message = "No data in the system."
			c.error = error
			return render("users/error.mako")
		c.tasks = tasks
		return render("tasks/index.mako")		
Beispiel #14
0
	def show(self, id):
		message = model.Message.query().get(id)
		if message is None:
			error = Error()
			error.id = 2
			error.message = "Message with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")
		c.messages = [message]
		return render('messages/index.mako')
Beispiel #15
0
	def sent(self, id):
		messages = model.Message.query().filter(Message.from_msg == id).all()
		if len(messages) == 0:
			error = Error()
			error.id = 1
			error.message = "No data in the system."
			c.error = error
			return render("users/error.mako")
		c.messages = messages			
		return render('messages/index.mako')				
Beispiel #16
0
	def filter_by_team(self, id):
		result = model.Project.query().filter(Project.owned_by_prj == id).all()
		if len(result) == 0: #nothing in db
			error = Error()
			error.id = 1
			error.message = "Team with id %s has no projects" % id
			c.error = error
			return render("users/error.mako")
		c.projects = result
		return render("projects/index.mako")
Beispiel #17
0
 def index(self):
     result = model.Document.query().all()
     if len(result) == 0:
         error = Error()
         error.id = 1
         error.message = "No data in the system"
         c.error = error
         return render("users/error.mako")
     c.documents = result
     return render("documents/index.mako")
Beispiel #18
0
	def parteneri_for_user(self, id):
		result = model.Contact.query().filter(or_(Contact.addedby_con == id, Contact.visible_con == 0)).filter(Contact.tip_con == 2).all()
		if len(result) == 0:
			error = Error()
			error.id = 1
			error.message = "No data in the system."
			c.error = error
			return render("users/error.mako")
		c.contacts = result			
		return render('/contacts/index.mako')								
Beispiel #19
0
	def index(self):
		result = model.Project.query().all()
		if len(result) == 0: #nothing in db
			error = Error()
			error.id = 1
			error.message = "No data in the system"
			c.error = error
			return render("users/error.mako")		
		c.projects = result
		return render('projects/index.mako')
Beispiel #20
0
	def parteneri(self):
		result = model.Contact.query().filter(Contact.tip_con == 2).all()
		if len(result) == 0:
			error = Error()
			error.id = 1
			error.message = "No data in the system."
			c.error = error
			return render("users/error.mako")
		c.contacts = result			
		return render('/contacts/index.mako')				
Beispiel #21
0
	def show(self, id):
		result = model.User.query().get(id)
		if result is None:
			error = Error()
			error.id = 2
			error.message = "The user with the id %s does not exist" % id
			c.error = error
			return render("users/error.mako")
		c.user = result
		return render("users/login.mako")
Beispiel #22
0
	def show(self, id):
		result = model.Contact.query().get(id)
		if result == None:
			error = Error()
			error.id = 1
			error.message = "Contact with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")
		c.contacts = [result]
		return render('/contacts/index.mako')
Beispiel #23
0
	def login(self, username, password):	
		result = model.User.query().filter(User.email_usr == username).filter(User.password_usr == password).all()
		if result is None or len(result) == 0:
			error = Error()
			error.id = 3
			error.message = "Bad username or password"
			c.error = error
			return render("users/error.mako")
		c.user = result[0]
		return render("users/login.mako")
Beispiel #24
0
	def delete(self, id):
		meeting = model.Meeting.query().get(id)
		if meeting is None:
			error = Error()
			error.id = 1
			error.message = "Meeting with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")			
		model.meta.Session.delete(meeting)
		model.meta.Session.commit()
		return render("users/opstatus.mako")
Beispiel #25
0
	def delete(self, id):
		contact = model.Contact.query().get(id)
		if contact == None:
			error = Error()
			error.id = 1
			error.message = "Contact with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")		
		model.meta.Session.delete(contact)
		model.meta.Session.commit()
		return render("users/opstatus.mako")	
Beispiel #26
0
	def delete(self, id):
		task = model.Task.query().get(id)
		if task is None:
			error = Error()
			error.id = 1
			error.message = "Task with id %s does not exist." % id
			c.error = error
			return render("users/error.mako")			
		model.meta.Session.delete(task)
		model.meta.Session.commit()
		return render("users/opstatus.mako")
Beispiel #27
0
 def delete(self, id):
     document = model.Document.query().get(id)
     if document is None:
         error = Error()
         error.id = 2
         error.message = "The document with id %s does not exist" % id
         c.error = error
         return render("users/error.mako")
     model.meta.Session.delete(document)
     model.meta.Session.commit()
     return render("users/opstatus.mako")
Beispiel #28
0
	def show(self, id):
		"""GET /teams/id: Show a specific item."""
		# url('teams', id=ID)		
		result = model.Team.query().get(id)
		if result is None:
			error = Error()
			error.id = 2
			error.message = "The team with the id %s does not exist" % id
			c.error = error
			return render("users/error.mako")
		c.teams = [result]
		return render("teams/index.mako")
Beispiel #29
0
	def delete(self, id):
		team = model.Team.query().get(id)
		if team is None:
			error = Error()
			error.id = 2
			error.message = "The team with the id %s does not exist" % id
			c.error = error
			return render("users/error.mako")
			
		model.meta.Session.delete(team)
		model.meta.Session.commit()
		return render("users/opstatus.mako")
Beispiel #30
0
	def delete(self, id):
		user = model.User.query().get(id)
		if user is None:
			error = Error()
			error.id = 2
			error.message = "The user with the id %s does not exist" % id
			c.error = error
			return render("users/error.mako")
			
		model.meta.Session.delete(user)
		model.meta.Session.commit()
		return render("users/opstatus.mako")