<s> from django . core . urlresolvers import reverse <EOL> from django . db import models <EOL> from django . db . models . signals import post_save , post_delete <EOL> from django . dispatch import receiver <EOL> from model_utils . fields import AutoCreatedField , AutoLastModifiedField <EOL> from model_utils . models import TimeStampedModel <EOL> class PyPIMirrorPage ( TimeStampedModel ) : <EOL> package = models . ForeignKey ( "<STR_LIT>" , unique = True ) <EOL> content = models . TextField ( ) <EOL> def __unicode__ ( self ) : <EOL> return self . package . name <EOL> def get_relative_url ( self , current_url ) : <EOL> absolute_url_split = reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : self . package . name } ) . split ( "<STR_LIT:/>" ) <EOL> current_url_split = current_url . split ( "<STR_LIT:/>" ) <EOL> relative_url_split = absolute_url_split [ : ] <EOL> for i , part in enumerate ( absolute_url_split ) : <EOL> if len ( current_url_split ) > i and part == current_url_split [ i ] : <EOL> relative_url_split = relative_url_split [ <NUM_LIT:1> : ] <EOL> return "<STR_LIT:/>" . join ( relative_url_split ) <EOL> class PyPIServerSigPage ( TimeStampedModel ) : <EOL> package = models . ForeignKey ( "<STR_LIT>" ) <EOL> content = models . TextField ( ) <EOL> def __unicode__ ( self ) : <EOL> return self . package . name <EOL> class PyPIIndexPage ( models . Model ) : <EOL> created = AutoCreatedField ( "<STR_LIT>" , db_index = True ) <EOL> modified = AutoLastModifiedField ( "<STR_LIT>" ) <EOL> content = models . TextField ( ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % self . created . isoformat ( ) <EOL> class PyPIDownloadChange ( TimeStampedModel ) : <EOL> file = models . ForeignKey ( "<STR_LIT>" ) <EOL> change = models . IntegerField ( default = <NUM_LIT:0> ) <EOL> integrated = models . BooleanField ( default = False ) <EOL> @ receiver ( post_save , sender = PyPIMirrorPage ) <EOL> @ receiver ( post_delete , sender = PyPIMirrorPage ) <EOL> def regenerate_simple_index ( sender , ** kwargs ) : <EOL> from pypi . tasks import refresh_pypi_package_index_cache <EOL> refresh_pypi_package_index_cache . delay ( ) </s>
