Applications backend tweaks

Now checking if current user has already reviewed an application.
This commit is contained in:
2014-07-14 20:09:08 +02:00
parent ad9f75744f
commit 65440a2c31
2 changed files with 12 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ from application.helpers import pretty_date
from users import User
from sqlalchemy.ext.associationproxy import association_proxy
from flask.ext.security import current_user
class Application(db.Model):
@@ -41,6 +42,15 @@ class Application(db.Model):
else:
return '--'
def is_reviewed(self):
for review in ReviewersApplications.query.\
filter_by(application_id=self.id).\
all():
if review.reviewer_blender_id == current_user.id:
return True
else:
return False
@property
def user(self):
return User.query.get_or_404(self.blender_id)
@@ -65,7 +75,7 @@ skills_applications = db.Table('skills_applications',
class ReviewersApplications(db.Model):
id = db.Column(db.Integer(), primary_key=True)
application_id = db.Column(db.Integer(), db.ForeignKey(Application.id), nullable=False)
application = db.relationship('Application')
application = db.relationship('Application', backref='reviewers')
#reviewer_blender_id = db.Column(db.Integer(), db.ForeignKey(User.id), nullable=False)
#reviewer = db.relationship('User')
reviewer_blender_id = db.Column(db.Integer(), nullable=False)

View File

@@ -17,7 +17,7 @@
</thead>
<tbody>
{% for application in applications %}
<tr>
<tr class="{% if application.is_reviewed() %}reviewed{% endif %}">
<td class="relative">{{ application.id }}</td>
<td><a href="{{url_for('applications.view', id=application.id)}}" >
{{application.user.first_name}} {{application.user.last_name}}