<s> from datetime import datetime <EOL> from django . db . models import signals <EOL> from django . db import models <EOL> from premises . utils import int_or_zero <EOL> class FormRenderer ( object ) : <EOL> def as_p ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _html_output ( <EOL> normal_row = '<STR_LIT>' , <EOL> error_row = '<STR_LIT:%s>' , <EOL> row_ender = '<STR_LIT>' , <EOL> help_text_html = '<STR_LIT>' , <EOL> errors_on_separate_row = True ) <EOL> class DeletePreventionMixin ( models . Model ) : <EOL> is_deleted = models . BooleanField ( default = False ) <EOL> deleted_at = models . DateTimeField ( null = True , blank = True ) <EOL> class Meta : <EOL> abstract = True <EOL> def delete ( self , using = None ) : <EOL> signals . pre_delete . send ( <EOL> sender = self . __class__ , <EOL> instance = self <EOL> ) <EOL> self . is_deleted = True <EOL> self . deleted_at = datetime . now ( ) <EOL> self . save ( using = using ) <EOL> signals . post_delete . send ( <EOL> sender = self . __class__ , <EOL> instance = self <EOL> ) <EOL> class PaginationMixin ( object ) : <EOL> def get_offset ( self ) : <EOL> return int_or_zero ( self . request . GET . get ( "<STR_LIT>" ) ) <EOL> def get_limit ( self ) : <EOL> return self . get_offset ( ) + self . paginate_by <EOL> def has_next_page ( self ) : <EOL> total = self . get_contentions ( paginate = False ) . count ( ) <EOL> return total > ( self . get_offset ( ) + self . paginate_by ) <EOL> def get_next_page_url ( self ) : <EOL> offset = self . get_offset ( ) + self . paginate_by <EOL> return '<STR_LIT>' % { <EOL> "<STR_LIT>" : offset <EOL> } <EOL> class NextURLMixin ( object ) : <EOL> def get_view_name ( self ) : <EOL> view = self . request . GET . get ( "<STR_LIT>" ) <EOL> return view if view in [ "<STR_LIT>" , "<STR_LIT:list>" ] else "<STR_LIT>" <EOL> def get_next_parameter ( self ) : <EOL> if self . get_view_name ( ) == "<STR_LIT:list>" : <EOL> return "<STR_LIT>" <EOL> return "<STR_LIT>" </s>
