<s> from django import forms <EOL> from django . contrib . auth . models import User <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> try : <EOL> from notification import models as notification <EOL> except ImportError : <EOL> notification = None <EOL> from announcements . models import Announcement <EOL> class AnnouncementAdminForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> send_now = forms . BooleanField ( required = False , <EOL> help_text = _ ( "<STR_LIT>" ) ) <EOL> class Meta : <EOL> model = Announcement <EOL> exclude = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def save ( self , commit = True ) : <EOL> """<STR_LIT>""" <EOL> announcement = super ( AnnouncementAdminForm , self ) . save ( commit ) <EOL> if self . cleaned_data [ "<STR_LIT>" ] : <EOL> if notification : <EOL> users = User . objects . all ( ) <EOL> notification . send ( users , "<STR_LIT>" , { <EOL> "<STR_LIT>" : announcement , <EOL> } , on_site = False , queue = True ) <EOL> return announcement </s>
