Ejemplo n.º 1
0
def addproject():
	form = ProjectForm()

	if form.validate_on_submit():
		try:
			proj = Projects(author=g.user, title=form.title.data, content=form.content.data, timestamp=datetime.datetime.now(), members=[g.user])
			proj.save()
			flash('Proiectul a fost salvat!', category='alert-success')
			return redirect(url_for('projects.list'))
		except:
			flash('Proiectul nu poate fi salvat!', category='alert-danger')

	return render_template('projects/add.html', form=form, pagetitle='Adauga proiect')
Ejemplo n.º 2
0
def ajaxedit(action,value,id):

	if value == 'post':
		field = ProjPosts.objects(id=id).get()
	if value == 'comment':
		field = ProjComments.objects(id=id).get()
	if value == 'proj':
		field = Projects.objects(id=id).get()

	if action == 'delete' and (field.author == g.user or g.user.permissions == 'full'):
		if value == 'comment':
			post = field.reference
			post.update(pull__comments=field)
		if value == 'post':
			for f in field.comments:
				f.delete()
		if value == 'proj':
			for t in field.posts:
				for f in field.comments:
					f.delete() 
				t.delete()
		field.delete()


	return redirect(request.referrer)
Ejemplo n.º 3
0
def leaveproject(id):
	proj = Projects.objects(id=id).get()
	if len(proj.members) == 1:
		flash('Esti singurul membru al proiectului!', category='alert-danger')
	else:
		if g.user in proj.members:
			proj.update(pull__members=g.user)
			if g.user == proj.author:
				proj.update(set__author=proj.members[0])
		if g.user in proj.applicants:
			proj.update(pull__applicants=g.user)

	return redirect(request.referrer)
Ejemplo n.º 4
0
def applicantmod(id,apid,action):
	proj = Projects.objects(id=id).get()
	if g.user not in proj.members:
		flash('Nu poti face aceasta operatie!', category='alert-danger')
		return redirect(request.referrer)
	else:
		for x in proj.applicants:
			if unicode(x.id) == apid: 
				if action == 'accept':
					proj.update(push__members=x)
				proj.update(pull__applicants=x)

	return redirect(request.referrer)
Ejemplo n.º 5
0
def addpost(id):
	proj = Projects.objects(id=id).get()
	form = ProjPostForm()

	if form.validate_on_submit() and g.user in proj.members:
		try:
			post = ProjPosts(author=g.user, title=form.title.data, content=form.content.data, timestamp=datetime.datetime.now(), project=proj)
			post.save()
			proj.update(add_to_set__posts=post)
			flash('Postarea a fost salvata!', category='alert-success')
			return redirect(url_for('projects.detailproject',id=proj.id))
		except:
			flash('Postarea nu poate fi salvata!', category='alert-danger')

	return render_template('wall/add.html', form=form, pagetitle='Scrie postare')
Ejemplo n.º 6
0
def editproject(id):
	proj = Projects.objects(id=id).get()

	if form.validate_on_submit() and (proj.author == g.user or g.user.permissions == 'full'):
		try:
			proj.title = form.title.data
			proj.content = form.content.data
			proj.save()
			flash('Proiectul a fost editat!', category='alert-success')
			return redirect(request.args.get('next') or url_for('project.list'))
		except:
			flash('Proiectul nu poate fi editat!', category='alert-danger')

	form.title.data = proj.title
	form.content.data = proj.content

	return render_template('projects/add.html', form=form, pagetitle='Editeaza proiect')
Ejemplo n.º 7
0
def applyproject(id):
	proj = Projects.objects(id=id).get()
	proj.update(add_to_set__applicants=g.user)
	flash('Aplicatia ta a fost inregistrata si asteapta sa fie validata de catre un membru al proiectului!', category='alert-success')

	return redirect(request.referrer)
Ejemplo n.º 8
0
def detailproject(id):
	proj = Projects.objects(id=id).get()
	posts = [x for x in proj.posts]
	applicants = [x for x in proj.applicants]
	
	return render_template('projects/details.html', post=proj, results=posts)
Ejemplo n.º 9
0
def list():

	results = [x for x in Projects.objects().order_by('-timestamp')]

	return render_template('projects/list.html', results=results)