def get_recepient(t): if (t.__class__.__name__ == 'TextMessage'): if (t is not None and t.phone is not None): return t.phone else: return '' else: if (t is not None and t.sender is not None): if is_blacklisted(t.sender): return t.sender + "(B)" else: return t.sender else: return ''
def update_complaint_sequence(complaint): from cmh.issuemgr.models import Complaint todays_complaints = Complaint.objects.filter( created__year=complaint.created.year, created__month=complaint.created.month, created__day=complaint.created.day, original=None, ) todays_complaints = todays_complaints.order_by("created") first_complaint = todays_complaints[0] complaint.complaintno = "%s.%03d" % (complaint.created.strftime("%Y%m%d"), (complaint.id - first_complaint.id + 1)) complaint.save() # Since this person is being recognized as a valid complainant, remove this phone number from blacklist if it exists there from cmh.smsgateway.views import is_blacklisted, remove_from_blacklist if is_blacklisted(complaint.filedby.mobile): remove_from_blacklist(complaint.filedby.mobile)