<s> '''<STR_LIT>''' <EOL> from django . views . generic import date_based , create_update <EOL> from models import DatedMessage <EOL> from django . http import HttpResponseRedirect , HttpResponseNotAllowed <EOL> from django . core . urlresolvers import reverse <EOL> from forms import MessageForm <EOL> def list_msgs ( request , number = None ) : <EOL> '''<STR_LIT>''' <EOL> if request . method == "<STR_LIT:GET>" : <EOL> qs = DatedMessage . objects . get_messages_for_user ( request . user ) <EOL> if number == None : number = qs . count ( ) <EOL> return date_based . archive_index ( <EOL> request , <EOL> queryset = qs , <EOL> date_field = '<STR_LIT>' , <EOL> num_latest = number , <EOL> template_name = '<STR_LIT>' , <EOL> extra_context = { '<STR_LIT>' : number } <EOL> ) <EOL> elif request . method == "<STR_LIT:POST>" : <EOL> msg_ids = request . POST . getlist ( "<STR_LIT>" ) <EOL> qs = DatedMessage . objects . filter ( id__in = msg_ids ) <EOL> DatedMessage . objects . delete_messages_for_user ( qs , request . user ) <EOL> if number : <EOL> return HttpResponseRedirect ( <EOL> reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : number } ) ) <EOL> else : <EOL> return HttpResponseRedirect ( <EOL> reverse ( "<STR_LIT>" ) ) <EOL> return HttpResponseNotAllowed ( "<STR_LIT:GET>" , "<STR_LIT:POST>" ) <EOL> def create ( request ) : <EOL> '''<STR_LIT>''' <EOL> return create_update . create_object ( <EOL> request , <EOL> form_class = MessageForm , <EOL> template_name = "<STR_LIT>" , <EOL> post_save_redirect = reverse ( "<STR_LIT>" ) , <EOL> ) </s>
