Commit 9529067c authored by William Colmenares's avatar William Colmenares

added messages support, more clean html

parent 2806ccbb
from django.contrib import admin
from .models import Job, Application, Tag, Question, Answer
from .models import Job, Application, Tag, Question, Answer, JobMessage
admin.site.register([Job, Application, Tag, Question, Answer])
admin.site.register([Job, Application, Tag, Question, Answer, JobMessage])
......@@ -2,7 +2,7 @@ from django import forms
from django.forms import inlineformset_factory
from dal.autocomplete import ModelSelect2Multiple
from .models import Job, Question, Application, Answer
from .models import Job, Question, Application, Answer, JobMessage
class JobForm(forms.ModelForm):
......@@ -13,6 +13,12 @@ class JobForm(forms.ModelForm):
'tags': ModelSelect2Multiple(url='jobs:tag-autocomplete')
}
class MessageForm(forms.ModelForm):
text = forms.CharField(label='', widget=forms.TextInput(attrs={"placeholder": "Write your message"}))
class Meta:
model = JobMessage
fields = ('text',)
class QuestionForm(forms.ModelForm):
class Meta:
......
......@@ -42,6 +42,8 @@ class Job(models.Model):
posted_by = models.ForeignKey(
User, related_name="jobs", on_delete=models.CASCADE)
active = models.BooleanField(default=True)
def renew(self):
self.expires = after_30_days()
self.save()
......@@ -96,3 +98,13 @@ class Answer(models.Model):
def __str__(self):
return "Answer for : {0} - {1}".format(self.question, self.application)
class JobMessage(models.Model):
"""Basic user to user messaging app"""
sender = models.ForeignKey(User, on_delete=models.CASCADE, related_name="sender")
receiver = models.ForeignKey(User, on_delete=models.CASCADE, related_name="receiver")
text = models.TextField()
date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return '{}, {}'.format(self.sender, self.text[:50])
{% extends 'base.html' %}
{% block body_content %}
<div class="row">
<div class="col-md-12">
<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4">Applications</h1>
<p class="lead"></p>
</div>
{% for application in applications %}
<div class="card">
<div class="card-body">
<h4 class="card-title">
<a href="{{ application.get_absolute_url }}">Submitted by: {{ application.applicant }}</a>
</h4>
<p class="card-text">
Submitted: {{ application.created }}
</p>
<p class="card-text">
{{ application.cover_text }}
</p>
<ol>
{% for answer in application.answers.all %}
<li>{{answer.question}}<p>{{answer.text}}</p></li>
{% endfor %}
</ol>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% block body_content %}
<div class="row">
<div class="col-md-12">
<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="h2 text-center">{{ title }}</h1>
<p class="lead"></p>
</div>
</div>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
</div>
{% endblock %}
{% for jobmessage in jobmessages %}
{% endfor %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment