<s> from __future__ import unicode_literals <EOL> from django import forms <EOL> from django . contrib import admin <EOL> from django . contrib . auth . admin import UserAdmin <EOL> from django . contrib . auth . forms import UserChangeForm , UserCreationForm <EOL> from django . contrib . auth . models import User <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from reviewboard . accounts . models import ( ReviewRequestVisit , Profile , <EOL> LocalSiteProfile ) <EOL> from reviewboard . reviews . models import Group <EOL> USERNAME_REGEX = r'<STR_LIT>' <EOL> USERNAME_HELP_TEXT = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> USERNAME_ERROR_MESSAGE = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class RBUserChangeForm ( UserChangeForm ) : <EOL> """<STR_LIT>""" <EOL> username = forms . RegexField ( <EOL> label = _ ( "<STR_LIT>" ) , max_length = <NUM_LIT:30> , <EOL> regex = USERNAME_REGEX , <EOL> help_text = USERNAME_HELP_TEXT , <EOL> error_message = USERNAME_ERROR_MESSAGE ) <EOL> class RBUserCreationForm ( UserCreationForm ) : <EOL> """<STR_LIT>""" <EOL> username = forms . RegexField ( <EOL> label = _ ( "<STR_LIT>" ) , max_length = <NUM_LIT:30> , <EOL> regex = USERNAME_REGEX , <EOL> help_text = USERNAME_HELP_TEXT , <EOL> error_message = USERNAME_ERROR_MESSAGE ) <EOL> class ProfileInline ( admin . StackedInline ) : <EOL> """<STR_LIT>""" <EOL> model = Profile <EOL> raw_id_fields = ( '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> fieldsets = ( <EOL> ( _ ( '<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> } ) , <EOL> ( _ ( '<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> } ) , <EOL> ( _ ( '<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> } ) , <EOL> ) <EOL> class LocalSiteProfileInline ( admin . StackedInline ) : <EOL> """<STR_LIT>""" <EOL> model = LocalSiteProfile <EOL> exclude = ( '<STR_LIT>' , ) <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> extra = <NUM_LIT:0> <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> } ) , <EOL> ( _ ( '<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> } ) , <EOL> ) <EOL> class RBUserAdmin ( UserAdmin ) : <EOL> """<STR_LIT>""" <EOL> form = RBUserChangeForm <EOL> add_form = RBUserCreationForm <EOL> filter_vertical = ( '<STR_LIT>' , ) <EOL> filter_horizontal = ( ) <EOL> inlines = [ <EOL> ProfileInline , <EOL> LocalSiteProfileInline , <EOL> ] <EOL> class ReviewRequestVisitAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' ) <EOL> raw_id_fields = ( '<STR_LIT>' , ) <EOL> class ProfileAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raw_id_fields = ( '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class LocalSiteProfileAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> list_display = ( '<STR_LIT>' , ) <EOL> raw_id_fields = ( '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def fix_review_counts ( ) : <EOL> """<STR_LIT>""" <EOL> LocalSiteProfile . objects . update ( <EOL> direct_incoming_request_count = None , <EOL> total_incoming_request_count = None , <EOL> pending_outgoing_request_count = None , <EOL> total_outgoing_request_count = None , <EOL> starred_public_request_count = None ) <EOL> Group . objects . update ( incoming_request_count = None ) <EOL> admin . site . unregister ( User ) <EOL> admin . site . register ( User , RBUserAdmin ) <EOL> admin . site . register ( ReviewRequestVisit , ReviewRequestVisitAdmin ) <EOL> admin . site . register ( Profile , ProfileAdmin ) <EOL> admin . site . register ( LocalSiteProfile , LocalSiteProfileAdmin ) </s>
