def add_candidate(self, musician): if not self.active: raise ValueError("O anúncio %d está inativo" % self.id) if musician in self.candidates.all(): return False self.candidates.add(musician) solicitation = Solicitation.objects.reply_announcement(musician, self.owner_band) EmailSender.announcement_reply(solicitation, self) return True
def ask_to_add(self, sender_musician, target_musician, band, instruments): if not band.musicians.get(musician=sender_musician).is_admin: raise ValueError('Esse musico nao pode enviar solicitacao para essa banda') if target_musician.is_in_band(band): raise ValueError("O musico %s ja pertence a banda %s" % (target_musician, band)) solicitation = self.__generate_solicitation(from_musician=sender_musician, to_musician=target_musician, band=band) solicitation.solicitation_type = Type.ADD_TO_BAND solicitation.save() solicitation.instruments = instruments EmailSender.add_in_band(solicitation) return True
def send_message(self, from_user, to, subject, txt): message = Message.objects.create(from_user=from_user, to_user=to, text=txt, subject=subject) EmailSender.message_received(message) return message