<s> import os <EOL> from django . db import models <EOL> from django . utils . translation import ugettext_lazy as _ , ugettext <EOL> from ionyweb . plugin . models import AbstractPlugin <EOL> from ionyweb . settings import VERSIONS <EOL> class Plugin_Image ( AbstractPlugin ) : <EOL> ALIGNMENT_CHOICES = ( <EOL> ( '<STR_LIT:C>' , _ ( u'<STR_LIT>' ) ) , <EOL> ( '<STR_LIT:L>' , _ ( u'<STR_LIT>' ) ) , <EOL> ( '<STR_LIT:R>' , _ ( u'<STR_LIT>' ) ) , <EOL> ) <EOL> image = models . CharField ( _ ( u'<STR_LIT>' ) , <EOL> max_length = <NUM_LIT:255> ) <EOL> description = models . CharField ( _ ( u'<STR_LIT:description>' ) , <EOL> max_length = <NUM_LIT:255> , <EOL> blank = True ) <EOL> width = models . PositiveIntegerField ( _ ( u"<STR_LIT:width>" ) , <EOL> blank = True , <EOL> null = True ) <EOL> height = models . PositiveIntegerField ( _ ( u"<STR_LIT>" ) , <EOL> blank = True , <EOL> null = True ) <EOL> lightbox = models . BooleanField ( _ ( '<STR_LIT>' ) , <EOL> default = True ) <EOL> alignment = models . CharField ( _ ( '<STR_LIT>' ) , max_length = <NUM_LIT:1> , <EOL> choices = ALIGNMENT_CHOICES , <EOL> default = '<STR_LIT:C>' ) <EOL> def __unicode__ ( self ) : <EOL> return u'<STR_LIT>' % ( self . pk , self . image ) <EOL> @ property <EOL> def file_name ( self ) : <EOL> if self . image : <EOL> try : <EOL> return self . image . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> except IndexError : <EOL> pass <EOL> return '<STR_LIT>' <EOL> @ property <EOL> def original_file ( self ) : <EOL> """<STR_LIT>""" <EOL> file_path = self . image <EOL> file_path , ext = file_path . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> file_path , suffix_version = file_path . rsplit ( '<STR_LIT:_>' , <NUM_LIT:1> ) <EOL> if suffix_version in VERSIONS . keys ( ) : <EOL> return u'<STR_LIT>' % ( file_path , ext ) <EOL> return self . image <EOL> class Meta : <EOL> verbose_name = ugettext ( u"<STR_LIT>" ) </s>
