def counteroffer(counteroffer, seller, buyer, book): subject = 'Neuer Preisvorschlag für das Buch ' + book.name msg = 'Der Benutzer ' + buyer.full_name() + ' möchte das Buch "'+book.name+'" für '+template_extras.currency(counteroffer.price)+' kaufen.' notification = Notification( sender_user=buyer, subject=subject, message=msg, received_date=datetime.now(), notification_type=Notification.COUNTEROFFER, receiver_user=seller, counter_offer=counteroffer, book=book ) notification.save() NotificationEmailThread(notification.receiver_user, notification.subject, notification.message).start()
def clean(self): cleaned_data = super(CounterofferForm, self).clean() price_myself = cleaned_data.get("price") offer_price = self.instance.offer.totalPrice() if price_myself > offer_price: msg = 'Der von Ihnen vorgeschlagene Preis ist höher als der Sofortkauf-Preis von ' + currency(offer_price) self.add_error('price', msg)
def counteroffer_accept(counteroffer, buyer, book, payment): # Preisvorschlag akzeptiert subject = 'Preisvorschlag für das Buch ' + book.name + ' wurde akzeptiert.' msg = 'Der von Ihnen vorgeschlagene Preis für das Buch: "' + book.name + '" in Höhe von ' + template_extras.currency(counteroffer.price) + ' wurde von dem Verkäufer akzeptiert.' notification = Notification( sender_user=counteroffer.offer.seller_user, subject=subject, message=msg, received_date=datetime.now(), notification_type=Notification.COUNTEROFFER_ACCEPT, receiver_user=buyer, counter_offer=counteroffer, payment=payment, book=book ) notification.save() NotificationEmailThread(notification.receiver_user, notification.subject, notification.message).start()