Add encrypted field to comment.

See #913
 - Legacy-Id: 5155
This commit is contained in:
Emilio Jiménez 2012-12-26 17:24:27 +00:00
parent e1a518720b
commit 5aad2aadff
2 changed files with 29 additions and 3 deletions

View file

@ -1,6 +1,31 @@
import tempfile
from django.conf import settings
from django.db import models
from ietf.utils.pipe import pipe
class EncriptedException(Exception):
pass
class EncriptedTextField(models.TextField):
""" TODO: do the logic to store encripted text"""
pass
def pre_save(self, instance, add):
if add:
comments = getattr(instance, 'comments')
position = getattr(instance, 'position')
cert_file = position.nomcom.public_key.path
comments_file = tempfile.NamedTemporaryFile()
comments_file.write(comments)
code, out, error = pipe("%s smime -encrypt -in %s %s" % (settings.OPENSSL_COMMAND,
comments_file.name,
cert_file))
comments_file.close()
if not error:
instance.comments = out
return out
else:
raise EncriptedException(error)
else:
return instance.comments

View file

@ -261,9 +261,10 @@ IDSUBMIT_ANNOUNCE_LIST_EMAIL = 'i-d-announce@ietf.org'
# NomCom Tool settings
ROLODEX_URL = ""
PUBLIC_KEYS_URL = BASE_DIR + "/public_keys/"
PUBLIC_KEYS_URL = BASE_DIR + '/public_keys/'
NOMCOM_FROM_EMAIL = DEFAULT_FROM_EMAIL
NOMCOM_ADMIN_EMAIL = DEFAULT_FROM_EMAIL
OPENSSL_COMMAND = '/usr/bin/openssl'
# Days from meeting to cut off dates on submit
FIRST_CUTOFF_DAYS = 19