<s> """<STR_LIT>""" <EOL> from django . shortcuts import get_object_or_404 <EOL> from django . template import RequestContext <EOL> from django . http import HttpResponseRedirect <EOL> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext as _ <EOL> from django . contrib import messages <EOL> from django . db . models import Q <EOL> from treeio . core . models import Object , ModuleSetting <EOL> from treeio . core . views import user_denied <EOL> from treeio . core . conf import settings <EOL> from treeio . core . rendering import render_to_response <EOL> from treeio . core . decorators import treeio_login_required , handle_response_format <EOL> from treeio . identities . models import ContactType , Contact <EOL> from treeio . messaging . models import Message , MessageStream , MailingList <EOL> from treeio . messaging . forms import MessageForm , MessageStreamForm , FilterForm , MassActionForm , SettingsForm , MessageReplyForm , MailingListForm <EOL> import re <EOL> def _get_filter_query ( args ) : <EOL> "<STR_LIT>" <EOL> query = Q ( ) <EOL> for arg in args : <EOL> if hasattr ( Message , arg ) and args [ arg ] : <EOL> kwargs = { str ( arg + '<STR_LIT>' ) : long ( args [ arg ] ) } <EOL> query = query & Q ( ** kwargs ) <EOL> return query <EOL> def _get_default_context ( request ) : <EOL> "<STR_LIT>" <EOL> streams = Object . filter_by_request ( request , MessageStream . objects ) <EOL> mlists = MailingList . objects . all ( ) <EOL> massform = MassActionForm ( request . user . profile ) <EOL> context = { '<STR_LIT>' : streams , <EOL> '<STR_LIT>' : mlists , <EOL> '<STR_LIT>' : massform } <EOL> return context <EOL> def _process_mass_form ( f ) : <EOL> "<STR_LIT>" <EOL> def wrap ( request , * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> if '<STR_LIT>' in request . POST : <EOL> for key in request . POST : <EOL> if '<STR_LIT>' in key : <EOL> try : <EOL> message = Message . objects . get ( pk = request . POST [ key ] ) <EOL> form = MassActionForm ( <EOL> user , request . POST , instance = message ) <EOL> if form . is_valid ( ) and user . has_permission ( message , mode = '<STR_LIT:w>' ) : <EOL> form . save ( ) <EOL> except Exception : <EOL> pass <EOL> try : <EOL> form = MassActionForm ( request . user . profile , request . POST ) <EOL> if form . is_valid ( ) : <EOL> form . save ( ) <EOL> except Exception : <EOL> pass <EOL> return f ( request , * args , ** kwargs ) <EOL> wrap . __doc__ = f . __doc__ <EOL> wrap . __name__ = f . __name__ <EOL> return wrap <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> @ _process_mass_form <EOL> def index ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> query = Q ( reply_to__isnull = True ) <EOL> if request . GET : <EOL> query = query & _get_filter_query ( request . GET ) <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> else : <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> filters = FilterForm ( request . user . profile , '<STR_LIT:title>' , request . GET ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : filters , <EOL> '<STR_LIT>' : objects } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> @ _process_mass_form <EOL> def index_sent ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> query = Q ( reply_to__isnull = True ) & Q ( <EOL> author = request . user . profile . get_contact ( ) ) <EOL> if request . GET : <EOL> query = query & _get_filter_query ( request . GET ) <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> else : <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> filters = FilterForm ( request . user . profile , '<STR_LIT:title>' , request . GET ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : filters , <EOL> '<STR_LIT>' : objects } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> @ _process_mass_form <EOL> def index_inbox ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> query = Q ( reply_to__isnull = True ) & ~ Q ( <EOL> author = request . user . profile . get_contact ( ) ) <EOL> if request . GET : <EOL> query = query & _get_filter_query ( request . GET ) <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> else : <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> filters = FilterForm ( request . user . profile , '<STR_LIT:title>' , request . GET ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : filters , <EOL> '<STR_LIT>' : objects } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> @ _process_mass_form <EOL> def index_unread ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> query = Q ( reply_to__isnull = True ) & ~ Q ( read_by = user ) <EOL> if request . GET : <EOL> query = query & _get_filter_query ( request . GET ) <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> else : <EOL> objects = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) <EOL> filters = FilterForm ( request . user . profile , '<STR_LIT:title>' , request . GET ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : filters , <EOL> '<STR_LIT>' : objects } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def stream_add ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> if request . POST : <EOL> if '<STR_LIT>' not in request . POST : <EOL> stream = MessageStream ( ) <EOL> form = MessageStreamForm ( user , request . POST , instance = stream ) <EOL> if form . is_valid ( ) : <EOL> stream = form . save ( ) <EOL> stream . set_user_from_request ( request ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> form = MessageStreamForm ( user ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : form } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> @ _process_mass_form <EOL> def stream_view ( request , stream_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> stream = get_object_or_404 ( MessageStream , pk = stream_id ) <EOL> if not request . user . profile . has_permission ( stream ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> if request . user . profile . has_permission ( stream , mode = '<STR_LIT:x>' ) : <EOL> if request . POST : <EOL> message = Message ( ) <EOL> message . author = user . get_contact ( ) <EOL> if not message . author : <EOL> return user_denied ( request , <EOL> message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> form = MessageForm ( <EOL> request . user . profile , None , None , request . POST , instance = message ) <EOL> if form . is_valid ( ) : <EOL> message = form . save ( ) <EOL> message . recipients . add ( user . get_contact ( ) ) <EOL> message . set_user_from_request ( request ) <EOL> message . read_by . add ( user ) <EOL> try : <EOL> if '<STR_LIT>' in request . POST and request . POST [ '<STR_LIT>' ] : <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_contact_type = ContactType . objects . get ( <EOL> pk = long ( conf . value ) ) <EOL> except Exception : <EOL> default_contact_type = None <EOL> emails = request . POST [ <EOL> '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> for email in emails : <EOL> emailstr = unicode ( email ) . strip ( ) <EOL> if re . match ( '<STR_LIT>' , emailstr ) : <EOL> contact , created = Contact . get_or_create_by_email ( <EOL> emailstr , contact_type = default_contact_type ) <EOL> message . recipients . add ( contact ) <EOL> if created : <EOL> contact . set_user_from_request ( request ) <EOL> except : <EOL> pass <EOL> message . send_email ( ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ stream . id ] ) ) <EOL> else : <EOL> form = MessageForm ( request . user . profile , stream_id ) <EOL> else : <EOL> form = None <EOL> objects = Object . filter_by_request ( request , Message . objects . filter ( <EOL> reply_to__isnull = True , stream = stream ) . order_by ( '<STR_LIT>' ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : objects , <EOL> '<STR_LIT>' : form , <EOL> '<STR_LIT>' : stream } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def stream_edit ( request , stream_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> stream = get_object_or_404 ( MessageStream , pk = stream_id ) <EOL> if not request . user . profile . has_permission ( stream , mode = "<STR_LIT:w>" ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> if request . POST : <EOL> if '<STR_LIT>' not in request . POST : <EOL> form = MessageStreamForm ( user , request . POST , instance = stream ) <EOL> if form . is_valid ( ) : <EOL> stream = form . save ( ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ stream . id ] ) ) <EOL> else : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ stream . id ] ) ) <EOL> else : <EOL> form = MessageStreamForm ( user , instance = stream ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : form , <EOL> '<STR_LIT>' : stream } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def stream_checkmail ( request , stream_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> stream = get_object_or_404 ( MessageStream , pk = stream_id ) <EOL> if not user . has_permission ( stream ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> try : <EOL> stream . process_email ( ) <EOL> messages . add_message ( <EOL> request , messages . INFO , _ ( "<STR_LIT>" ) , fail_silently = True ) <EOL> except : <EOL> try : <EOL> messages . add_message ( request , messages . ERROR , _ ( <EOL> "<STR_LIT>" ) , fail_silently = True ) <EOL> except : <EOL> pass <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ stream . id ] ) ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def stream_delete ( request , stream_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> stream = get_object_or_404 ( MessageStream , pk = stream_id ) <EOL> if not request . user . profile . has_permission ( stream , mode = "<STR_LIT:w>" ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> if request . POST : <EOL> if '<STR_LIT>' in request . POST : <EOL> if '<STR_LIT>' in request . POST : <EOL> stream . trash = True <EOL> stream . save ( ) <EOL> else : <EOL> stream . delete ( ) <EOL> return HttpResponseRedirect ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in request . POST : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ stream . id ] ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : stream } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def messaging_compose ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> if request . POST : <EOL> if '<STR_LIT>' not in request . POST : <EOL> message = Message ( ) <EOL> message . author = user . get_contact ( ) <EOL> if not message . author : <EOL> return user_denied ( request , <EOL> message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> form = MessageForm ( <EOL> request . user . profile , None , None , request . POST , instance = message ) <EOL> if form . is_valid ( ) : <EOL> message = form . save ( ) <EOL> message . recipients . add ( user . get_contact ( ) ) <EOL> message . set_user_from_request ( request ) <EOL> message . read_by . add ( user ) <EOL> try : <EOL> if '<STR_LIT>' in request . POST and request . POST [ '<STR_LIT>' ] : <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_contact_type = ContactType . objects . get ( <EOL> pk = long ( conf . value ) ) <EOL> except Exception : <EOL> default_contact_type = None <EOL> emails = request . POST [ <EOL> '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> for email in emails : <EOL> emailstr = unicode ( email ) . strip ( ) <EOL> if re . match ( '<STR_LIT>' , emailstr ) : <EOL> contact , created = Contact . get_or_create_by_email ( <EOL> emailstr , contact_type = default_contact_type ) <EOL> message . recipients . add ( contact ) <EOL> if created : <EOL> contact . set_user_from_request ( request ) <EOL> except : <EOL> pass <EOL> message . send_email ( ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> form = MessageForm ( request . user . profile , None ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : form } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def messaging_view ( request , message_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> message = get_object_or_404 ( Message , pk = message_id ) <EOL> user = request . user . profile <EOL> if not user . has_permission ( message ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> message . read_by . add ( user ) <EOL> if request . POST and request . POST . get ( '<STR_LIT:body>' , False ) : <EOL> "<STR_LIT>" <EOL> reply = Message ( ) <EOL> reply . author = user . get_contact ( ) <EOL> if not reply . author : <EOL> return user_denied ( request , <EOL> message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> reply . reply_to = message <EOL> form = MessageReplyForm ( <EOL> user , message . stream_id , message , request . POST , instance = reply ) <EOL> if form . is_valid ( ) : <EOL> reply = form . save ( ) <EOL> reply . set_user_from_request ( request ) <EOL> reply . recipients . add ( reply . author ) <EOL> message . read_by . clear ( ) <EOL> try : <EOL> if '<STR_LIT>' in request . POST and request . POST [ '<STR_LIT>' ] : <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_contact_type = ContactType . objects . get ( <EOL> pk = long ( conf . value ) ) <EOL> except Exception : <EOL> default_contact_type = None <EOL> emails = request . POST [ <EOL> '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) <EOL> for email in emails : <EOL> emailstr = unicode ( email ) . strip ( ) <EOL> if re . match ( '<STR_LIT>' , emailstr ) : <EOL> contact , created = Contact . get_or_create_by_email ( <EOL> emailstr , contact_type = default_contact_type ) <EOL> reply . recipients . add ( contact ) <EOL> if created : <EOL> contact . set_user_from_request ( request ) <EOL> except : <EOL> pass <EOL> for recipient in reply . recipients . all ( ) : <EOL> message . recipients . add ( recipient ) <EOL> reply . send_email ( ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ message . id ] ) ) <EOL> else : <EOL> form = MessageReplyForm ( <EOL> request . user . profile , message . stream_id , message ) <EOL> replies = Object . filter_by_request ( request , <EOL> Message . objects . filter ( reply_to = message ) . order_by ( '<STR_LIT>' ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT:message>' : message , <EOL> '<STR_LIT>' : replies , <EOL> '<STR_LIT>' : form } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def messaging_delete ( request , message_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> message = get_object_or_404 ( Message , pk = message_id ) <EOL> if not request . user . profile . has_permission ( message , mode = "<STR_LIT:w>" ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> if request . POST : <EOL> if '<STR_LIT>' in request . POST : <EOL> if '<STR_LIT>' in request . POST : <EOL> message . trash = True <EOL> message . save ( ) <EOL> else : <EOL> message . delete ( ) <EOL> return HttpResponseRedirect ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in request . POST : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ message . stream . id ] ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT:message>' : message } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> """<STR_LIT>""" <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def mlist_add ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> if request . POST : <EOL> mlist = MailingList ( ) <EOL> form = MailingListForm ( user , request . POST , instance = mlist ) <EOL> if form . is_valid ( ) : <EOL> mlist = form . save ( ) <EOL> mlist . set_user_from_request ( request ) <EOL> return HttpResponseRedirect ( '<STR_LIT>' ) <EOL> else : <EOL> form = MailingListForm ( user ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : form } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> @ _process_mass_form <EOL> def mlist_view ( request , mlist_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> mlist = get_object_or_404 ( MailingList , pk = mlist_id ) <EOL> if not request . user . profile . has_permission ( mlist ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> if request . user . profile . has_permission ( mlist , mode = '<STR_LIT:x>' ) : <EOL> if request . POST : <EOL> message = Message ( ) <EOL> message . author = request . user . profile . get_contact ( ) <EOL> if not message . author : <EOL> return user_denied ( request , <EOL> message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> form = MessageForm ( <EOL> request . user . profile , mlist_id , None , request . POST , instance = message ) <EOL> if form . is_valid ( ) : <EOL> message = form . save ( ) <EOL> message . set_user_from_request ( request ) <EOL> message . read_by . add ( user ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ mlist . id ] ) ) <EOL> else : <EOL> form = MessageForm ( request . user . profile , mlist_id ) <EOL> else : <EOL> form = None <EOL> messages = Object . filter_by_request ( request , <EOL> Message . objects . filter ( reply_to__isnull = True , <EOL> mlist = mlist ) . order_by ( '<STR_LIT>' ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : messages , <EOL> '<STR_LIT>' : form , <EOL> '<STR_LIT>' : mlist } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def mlist_edit ( request , mlist_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> user = request . user . profile <EOL> mlist = get_object_or_404 ( MailingList , pk = mlist_id ) <EOL> if not user . has_permission ( mlist , mode = "<STR_LIT:w>" ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : mlist } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def mlist_delete ( request , mlist_id , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> mlist = get_object_or_404 ( MailingList , pk = mlist_id ) <EOL> if not request . user . profile . has_permission ( mlist , mode = "<STR_LIT:w>" ) : <EOL> return user_denied ( request , message = "<STR_LIT>" , <EOL> response_format = response_format ) <EOL> if request . POST : <EOL> if '<STR_LIT>' in request . POST : <EOL> if '<STR_LIT>' in request . POST : <EOL> mlist . trash = True <EOL> mlist . save ( ) <EOL> else : <EOL> mlist . delete ( ) <EOL> return HttpResponseRedirect ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in request . POST : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' , args = [ mlist . id ] ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : mlist } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> """<STR_LIT>""" <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def settings_view ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( '<STR_LIT>' , '<STR_LIT>' , <EOL> user = request . user . profile ) [ <NUM_LIT:0> ] <EOL> default_contact_type = ContactType . objects . get ( pk = long ( conf . value ) ) <EOL> except : <EOL> default_contact_type = None <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> default_imap_folder = conf . value <EOL> except : <EOL> default_imap_folder = getattr ( <EOL> settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> try : <EOL> conf = ModuleSetting . get_for_module ( '<STR_LIT>' , '<STR_LIT>' , <EOL> user = request . user . profile , strict = True ) [ <NUM_LIT:0> ] <EOL> signature = conf . value <EOL> except : <EOL> signature = '<STR_LIT>' <EOL> types = Object . filter_by_request ( <EOL> request , ContactType . objects . order_by ( '<STR_LIT:name>' ) ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : types , <EOL> '<STR_LIT>' : signature , <EOL> '<STR_LIT>' : default_contact_type , <EOL> '<STR_LIT>' : default_imap_folder } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ handle_response_format <EOL> @ treeio_login_required <EOL> def settings_edit ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> if request . POST : <EOL> if '<STR_LIT>' not in request . POST : <EOL> form = SettingsForm ( request . user . profile , request . POST ) <EOL> if form . is_valid ( ) : <EOL> form . save ( ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> form = SettingsForm ( request . user . profile ) <EOL> context = _get_default_context ( request ) <EOL> context . update ( { '<STR_LIT>' : form } ) <EOL> return render_to_response ( '<STR_LIT>' , context , <EOL> context_instance = RequestContext ( request ) , <EOL> response_format = response_format ) <EOL> @ treeio_login_required <EOL> def widget_new_messages ( request , response_format = '<STR_LIT:html>' ) : <EOL> "<STR_LIT>" <EOL> query = Q ( reply_to__isnull = True ) & ~ Q ( read_by = request . user . profile ) <EOL> messages = Object . filter_by_request ( <EOL> request , Message . objects . filter ( query ) ) [ : <NUM_LIT:5> ] <EOL> return render_to_response ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : messages } , <EOL> context_instance = RequestContext ( request ) , response_format = response_format ) </s>
