<s> """<STR_LIT>""" <EOL> from django import forms <EOL> from django . utils . translation import ugettext as _ , ugettext_lazy <EOL> from modoboa . lib . email_utils import split_mailbox <EOL> from modoboa . lib . exceptions import BadRequest , PermDeniedException <EOL> from . . models import Domain <EOL> class ForwardForm ( forms . Form ) : <EOL> dest = forms . CharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> widget = forms . Textarea ( attrs = { "<STR_LIT:class>" : "<STR_LIT>" } ) , <EOL> required = False , <EOL> help_text = ugettext_lazy ( <EOL> "<STR_LIT>" ) <EOL> ) <EOL> keepcopies = forms . BooleanField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> required = False , <EOL> help_text = ugettext_lazy ( <EOL> "<STR_LIT>" ) <EOL> ) <EOL> def get_recipients ( self ) : <EOL> recipients = [ ] <EOL> rawdata = self . cleaned_data [ "<STR_LIT>" ] . strip ( ) <EOL> if not rawdata : <EOL> return recipients <EOL> for rcpt in rawdata . split ( "<STR_LIT:U+002C>" ) : <EOL> local_part , domname = split_mailbox ( rcpt ) <EOL> if not local_part or not domname : <EOL> raise BadRequest ( "<STR_LIT>" % rcpt ) <EOL> try : <EOL> Domain . objects . get ( name = domname ) <EOL> except Domain . DoesNotExist : <EOL> recipients += [ rcpt ] <EOL> else : <EOL> raise PermDeniedException ( <EOL> _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ) <EOL> return recipients </s>
