<s> from django . contrib import admin <EOL> from django . conf . urls . defaults import patterns , url <EOL> from django . utils . translation import ugettext as _ <EOL> from django . http import HttpResponseRedirect <EOL> from django . shortcuts import render_to_response <EOL> from django . template import RequestContext <EOL> from wurfl import update <EOL> from wurfl . models import Update , Patch <EOL> import operator <EOL> class UpdateAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def has_add_permission ( self , request ) : <EOL> return False <EOL> def update_hybrid_view ( self , request ) : <EOL> updates = update . hybrid ( ) <EOL> if any ( map ( operator . attrgetter ( '<STR_LIT>' ) , updates ) ) : <EOL> message = _ ( '<STR_LIT>' ) <EOL> else : <EOL> message = _ ( '<STR_LIT>' ) <EOL> request . user . message_set . create ( message = message ) <EOL> return HttpResponseRedirect ( request . path + "<STR_LIT>" ) <EOL> def update_wurfl_view ( self , request ) : <EOL> request . user . message_set . create ( message = _ ( '<STR_LIT>' ) ) <EOL> return HttpResponseRedirect ( request . path + "<STR_LIT>" ) <EOL> def get_urls ( self ) : <EOL> urls = super ( UpdateAdmin , self ) . get_urls ( ) <EOL> my_urls = patterns ( '<STR_LIT>' , <EOL> url ( r'<STR_LIT>' , self . admin_site . admin_view ( self . update_hybrid_view ) , name = "<STR_LIT>" ) , <EOL> url ( r'<STR_LIT>' , self . admin_site . admin_view ( self . update_wurfl_view ) , name = "<STR_LIT>" ) , <EOL> ) <EOL> return my_urls + urls <EOL> class PatchAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_filter = ( '<STR_LIT>' , '<STR_LIT>' , ) <EOL> search_fields = ( '<STR_LIT:name>' , ) <EOL> admin . site . register ( Update , UpdateAdmin ) <EOL> admin . site . register ( Patch , PatchAdmin ) </s>
