mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Applications now send a email and reddit notification message when the status is changed.
This commit is contained in:
31
hr/views.py
31
hr/views.py
@@ -6,6 +6,7 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
|
|
||||||
@@ -145,14 +146,28 @@ def update_application(request, applicationid):
|
|||||||
if not hrstaff and int(form.cleaned_data['new_status']) > 1:
|
if not hrstaff and int(form.cleaned_data['new_status']) > 1:
|
||||||
return HttpResponseRedirect(reverse('hr.views.index'))
|
return HttpResponseRedirect(reverse('hr.views.index'))
|
||||||
|
|
||||||
app.status = form.cleaned_data['new_status']
|
if not app.status == form.cleaned_data['new_status']:
|
||||||
app.save()
|
|
||||||
|
app.status = form.cleaned_data['new_status']
|
||||||
|
app.save()
|
||||||
|
|
||||||
if app.status == APPLICATION_STATUS_AWAITINGREVIEW:
|
def send_message(application, message_type):
|
||||||
app.user.message_set.create(message="Your application for %s to %s has been submitted." % (app.character, app.corporation))
|
from django.core.mail import send_mail
|
||||||
if app.status == APPLICATION_STATUS_ACCEPTED:
|
subject = render_to_string('hr/emails/%s_subject.txt' % message_type, { 'app': app })
|
||||||
app.user.message_set.create(message="Your application for %s to %s has been accepted." % (app.character, app.corporation))
|
subject = ''.join(subject.splitlines())
|
||||||
elif app.status == APPLICATION_STATUS_REJECTED:
|
message = render_to_string('hr/emails/%s.txt' % message_type, { 'app': app })
|
||||||
app.user.message_set.create(message="Your application for %s to %s has been rejected." % (app.character, app.corporation))
|
#send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [application.user.email])
|
||||||
|
|
||||||
|
if len(application.user.redditaccount_set.all()) > 0:
|
||||||
|
from reddit.api import Inbox
|
||||||
|
ib = Inbox(settings.REDDIT_USER, settings.REDDIT_PASSWD)
|
||||||
|
ib.send(application.user.redditaccount_set.all()[0].username, subject, message)
|
||||||
|
|
||||||
|
print app.status, APPLICATION_STATUS_ACCEPTED
|
||||||
|
if int(app.status) == APPLICATION_STATUS_ACCEPTED:
|
||||||
|
print "Yup!"
|
||||||
|
send_message(app, 'accepted')
|
||||||
|
elif app.status == APPLICATION_STATUS_REJECTED:
|
||||||
|
send_message(app, 'rejected')
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('hr.views.view_application', args=[applicationid]))
|
return HttpResponseRedirect(reverse('hr.views.view_application', args=[applicationid]))
|
||||||
|
|||||||
@@ -83,14 +83,11 @@ class Inbox():
|
|||||||
if not self.login_cookie:
|
if not self.login_cookie:
|
||||||
raise NotLoggedIn
|
raise NotLoggedIn
|
||||||
|
|
||||||
print self.login_cookie
|
|
||||||
|
|
||||||
data = { 'to': to,
|
data = { 'to': to,
|
||||||
'subject': subject,
|
'subject': subject,
|
||||||
'text': 'text',
|
'text': text,
|
||||||
'uh': self.modhash,
|
'uh': self.modhash,
|
||||||
'thing_id': '' }
|
'thing_id': '' }
|
||||||
url = "%s" % (self.REDDIT_API_COMPOSE)
|
url = "%s" % (self.REDDIT_API_COMPOSE)
|
||||||
|
|
||||||
jsondoc = json.load(self._url_request(url, data))
|
jsondoc = json.load(self._url_request(url, data))
|
||||||
print jsondoc
|
|
||||||
|
|||||||
9
templates/hr/emails/accepted.txt
Normal file
9
templates/hr/emails/accepted.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Hi {{ app.character }},
|
||||||
|
|
||||||
|
Congratulations, Your application to {{ app.corporation }} has been accepted. You will be accepted into the {{ app.corporation }} within the next 24 hours.
|
||||||
|
|
||||||
|
If you have any further questions regarding your application, please contact {{ app.corporation }} via the normal channels.
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
|
||||||
|
{{ app.corporation }} HR Bot
|
||||||
1
templates/hr/emails/accepted_subject.txt
Normal file
1
templates/hr/emails/accepted_subject.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Application to {{ app.corporation }} accepted.
|
||||||
11
templates/hr/emails/rejected.txt
Normal file
11
templates/hr/emails/rejected.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Hi {{ app.character }},
|
||||||
|
|
||||||
|
Your application to {{ app.corporation }} has been rejected.
|
||||||
|
|
||||||
|
One of our Personnel people will contact you in a seperate method to explain why you have been rejected.
|
||||||
|
|
||||||
|
If you have any further questions regarding your application, please contact {{ app.corporation }} via the normal channels.
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
|
||||||
|
{{ app.corporation }} HR Bot
|
||||||
1
templates/hr/emails/rejected_subject.txt
Normal file
1
templates/hr/emails/rejected_subject.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Application to {{ app.corporation }} rejected.
|
||||||
Reference in New Issue
Block a user