Applications backend tweaks
Now checking if current user has already reviewed an application.
This commit is contained in:
@@ -5,6 +5,7 @@ from application.helpers import pretty_date
|
|||||||
from users import User
|
from users import User
|
||||||
|
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
from flask.ext.security import current_user
|
||||||
|
|
||||||
|
|
||||||
class Application(db.Model):
|
class Application(db.Model):
|
||||||
@@ -41,6 +42,15 @@ class Application(db.Model):
|
|||||||
else:
|
else:
|
||||||
return '--'
|
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
|
@property
|
||||||
def user(self):
|
def user(self):
|
||||||
return User.query.get_or_404(self.blender_id)
|
return User.query.get_or_404(self.blender_id)
|
||||||
@@ -65,7 +75,7 @@ skills_applications = db.Table('skills_applications',
|
|||||||
class ReviewersApplications(db.Model):
|
class ReviewersApplications(db.Model):
|
||||||
id = db.Column(db.Integer(), primary_key=True)
|
id = db.Column(db.Integer(), primary_key=True)
|
||||||
application_id = db.Column(db.Integer(), db.ForeignKey(Application.id), nullable=False)
|
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_blender_id = db.Column(db.Integer(), db.ForeignKey(User.id), nullable=False)
|
||||||
#reviewer = db.relationship('User')
|
#reviewer = db.relationship('User')
|
||||||
reviewer_blender_id = db.Column(db.Integer(), nullable=False)
|
reviewer_blender_id = db.Column(db.Integer(), nullable=False)
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for application in applications %}
|
{% for application in applications %}
|
||||||
<tr>
|
<tr class="{% if application.is_reviewed() %}reviewed{% endif %}">
|
||||||
<td class="relative">{{ application.id }}</td>
|
<td class="relative">{{ application.id }}</td>
|
||||||
<td><a href="{{url_for('applications.view', id=application.id)}}" >
|
<td><a href="{{url_for('applications.view', id=application.id)}}" >
|
||||||
{{application.user.first_name}} {{application.user.last_name}}
|
{{application.user.first_name}} {{application.user.last_name}}
|
||||||
|
Reference in New Issue
Block a user