* Now Feedback have manytomany to posotions, so a feedback email can be associated to few positions. * Add user and time field to nomination model * Delete feedbacks and questionnaires field from nomineeposition model, now feedback model has all information about nominations, feedback and quiestionnaires * Add user field to Feedback model to know the nomcom meber who made the nomination, regardless of the real author * Add nomcom field to Feedback and refactor EncryptedTextField, it's necessary to encrypt the comments with the nomcom public key. * Template tag to decrypt feedback has been improved, now It isn't necessary the view context has the private key variable. * Add skel view to view feedback * Delete hidden fields from private and public feedback form * Refactor private index view to show total number of questionnaires and to show if the nomienee has questionnaires or not See #970 - Legacy-Id: 5571
35 lines
1,019 B
Python
35 lines
1,019 B
Python
import os
|
|
|
|
import tempfile
|
|
from django.conf import settings
|
|
from django.db import models
|
|
|
|
from ietf.utils.pipe import pipe
|
|
|
|
|
|
class EncryptedException(Exception):
|
|
pass
|
|
|
|
|
|
class EncryptedTextField(models.TextField):
|
|
def pre_save(self, instance, add):
|
|
if add:
|
|
comments = getattr(instance, 'comments')
|
|
nomcom = getattr(instance, 'nomcom')
|
|
cert_file = nomcom.public_key.path
|
|
comments_file = tempfile.NamedTemporaryFile(delete=False)
|
|
comments_file.write(comments)
|
|
comments_file.close()
|
|
|
|
code, out, error = pipe("%s smime -encrypt -in %s %s" % (settings.OPENSSL_COMMAND,
|
|
comments_file.name,
|
|
cert_file))
|
|
os.unlink(comments_file.name)
|
|
if not error:
|
|
instance.comments = out
|
|
return out
|
|
else:
|
|
raise EncryptedException(error)
|
|
else:
|
|
return instance.comments
|