<s> from django . shortcuts import render <EOL> try : <EOL> from . models import BasicFilesForm , FileForm <EOL> except ImportError : <EOL> from models import BasicFilesForm , FileForm <EOL> def pick ( request ) : <EOL> message = None <EOL> basic_form = BasicFilesForm ( ) <EOL> form = FileForm ( ) <EOL> if request . method == "<STR_LIT:POST>" : <EOL> post = request . POST . dict ( ) <EOL> basic_form = BasicFilesForm ( post ) <EOL> if basic_form . is_valid ( ) : <EOL> f = basic_form . save ( ) <EOL> post [ '<STR_LIT>' ] = f . id <EOL> else : <EOL> message = '<STR_LIT>' <EOL> files_links = request . POST [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> if post . get ( '<STR_LIT>' , None ) : <EOL> for i , f in enumerate ( request . FILES . getlist ( "<STR_LIT>" ) ) : <EOL> form = FileForm ( post ) <EOL> if form . is_valid ( ) : <EOL> fp = form . save ( commit = False ) <EOL> fp . fpfile = f <EOL> fp . fpurl = files_links [ i ] <EOL> fp . mid_id = post . get ( '<STR_LIT>' ) <EOL> fp . save ( ) <EOL> else : <EOL> message = "<STR_LIT>" <EOL> files = "<STR_LIT:U+002CU+0020>" . join ( [ str ( f ) for f in request . FILES . getlist ( "<STR_LIT>" ) ] ) <EOL> message = "<STR_LIT>" . format ( <EOL> files , request . POST [ "<STR_LIT>" ] ) if not message else message <EOL> return render ( request , "<STR_LIT>" , { '<STR_LIT>' : form , '<STR_LIT:message>' : message , '<STR_LIT>' : basic_form } ) </s>
