def reenvioPassword (request): """ Permite buscar a un padre al que se le regenerará la su password y se le enviará por sms junto a su nombre de usuario. """ context = {} pas = isPas(request.user) if not pas: context['error'] = 'Su usuario no está asignado a una cuenta de PAS' return render_to_response( "akademic/error.html", context, context_instance=RequestContext(request) ) if request.POST: new_data = request.POST.copy() if new_data.has_key('query'): search_fields = ['persona__documento_identificacion', 'persona__nombre', 'persona__apellidos'] for bit in new_data['query'].split(): or_queries = [models.Q(**{'%s__icontains' % field_name: bit}) for field_name in search_fields] context['padres'] = Padre.objects.filter(reduce(operator.or_, or_queries)) if not len(context['padres']): context['notFound'] = True elif new_data.has_key('padre'): passwd = User.objects.make_random_password(length=6) try: u = Padre.objects.get (persona = new_data['padre']) except Padre.DoesNotExist: return render_to_response( "akademic/error.html", context, context_instance=RequestContext(request) ) u.persona.user.set_password(passwd) u.persona.user.save() texto = "Nombre de usuario: %s Contraseña: %s" % (u.persona.user, passwd) t = TextoNotificacion(texto = texto) t.save () try: n = Notificacion( padre = u, alumno = u.get_hijos()[0], fechaCreacion = datetime.datetime.now(), fechaEnvio = None, texto = t, estado = ESTADO_NOTIFICACION[0][0], confidencial = True) n.save() except IndexError: return render_to_response( "akademic/error.html", context, context_instance=RequestContext(request) ) return render_to_response( TEMPLATES['pas_reenvio_pass'], context, context_instance=RequestContext(request) )
def handle(self, *app_labels, **options): self.listar = options.get('list', False) self.maximo_envios = int(options.get('maximo_envios', 1)) self.dryrun = options.get('dryrun', False) self.verbosity = int(options.get('verbosity', 1)) self.check_status = int(options.get('check_status', False)) log.debug(u'Enviando notificaciones') if self.verbosity == 2: print u"Enviando notificaciones" if self.maximo_envios: msg = u"Como máximo enviar %d notificaciones." % self.maximo_envios log.info(msg) if self.verbosity == 2: print msg if self.dryrun: msg = u'Enviando notificaciones en modo dry-run' log.info(msg) if self.verbosity == 2: print msg notificaciones_pendientes = Notificacion.get_pendientes() num_envios, saldo = self._check_saldo(len(notificaciones_pendientes)) if num_envios > 0: sent = self._envia_notificaciones_pendientes(notificaciones_pendientes) self._alerta_supervisores(sent, saldo) msg = u"Enviados %s mensajes." % sent log.info(msg) print msg if self.check_status: print u"Not implemented yet."
def handle(self, *app_labels, **options): # msg = u"Por favor, notificar al tutor mediante la agenda la recepción de este mensaje" # msg = u"Bienvenidos al curso 2009 2010. Roguemos confirmen la recepcion del SMS" # msg = u"Rogamos confirme la recepcion de este SMS en la carta enviada desde el Centro" msg = u"Bienvenidos al curso 2010-2011. Rogamos confirmen la recepción de este SMS en la carta que hoy le entregará su hijo/a" force = options.get('force', False) debug = options.get('debug', False) dry_run = options.get('dry_run', False) verbosity = int(options.get('verbosity', 1)) if verbosity == 2: print u"Modo verboso" if dry_run: print u"Modo dry_run" # padres_notificados = [] for p in Padre.objects.filter( ( Q(padre_hijos__grupoaulaalumno__grupo__curso__ciclo__nivel__cursoEscolar = settings.CURSO_ESCOLAR_ACTUAL) |\ Q(madre_hijos__grupoaulaalumno__grupo__curso__ciclo__nivel__cursoEscolar = settings.CURSO_ESCOLAR_ACTUAL) \ ) & Q(verificado__isnull=True) & Q(difunto=False) ).exclude(is_blanco = True).distinct()[1:]: # Evita padres repetidos # if p.id in padres_notificados: # if verbosity == 2: # print u"Obviando padre %s, debe tener más de un hijo." % p # continue filter = {"grupoaulaalumno__grupo__curso__ciclo__nivel__cursoEscolar": settings.CURSO_ESCOLAR_ACTUAL} if not p.get_hijos().filter(**filter).count(): continue if p.persona.tlf_movil() is '': continue # padres_notificados.append(p.id) if not dry_run: n = Notificacion.envia_notificacion(p, p.get_hijos()[0], msg, force=True) if verbosity == 2: print u"Notificación enviada: %s, %s" % (p, msg) if verbosity and not n: print u"No se ha podido enviar la notificación a %s porque no tenía teléfono móvil." % p else: if verbosity == 2: print u"DRY_RUN: Notificacion NO enviada: %s, %s" % (p, msg)
def _check_status(self): for notificacion in Notificacion.get_sin_estado(): # print notificacion estado = self._get_status(notificacion.plataformaId) print u"%s" % estado