<s> from __future__ import unicode_literals <EOL> from django . core . urlresolvers import reverse <EOL> from django . db import models <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . utils . text import slugify <EOL> from badgify import compat , settings <EOL> @ python_2_unicode_compatible <EOL> class Badge ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> name = models . CharField ( <EOL> max_length = <NUM_LIT:255> , <EOL> verbose_name = _ ( '<STR_LIT:name>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) ) <EOL> slug = models . SlugField ( <EOL> max_length = <NUM_LIT:255> , <EOL> blank = True , <EOL> unique = True , <EOL> verbose_name = _ ( '<STR_LIT>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) ) <EOL> description = models . TextField ( <EOL> blank = True , <EOL> verbose_name = _ ( '<STR_LIT:description>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) ) <EOL> image = models . ImageField ( null = True , blank = True , <EOL> verbose_name = _ ( '<STR_LIT>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) , <EOL> upload_to = settings . BADGE_IMAGE_UPLOAD_ROOT ) <EOL> users = models . ManyToManyField ( <EOL> compat . AUTH_USER_MODEL , <EOL> through = '<STR_LIT>' , <EOL> verbose_name = _ ( '<STR_LIT>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) ) <EOL> users_count = models . IntegerField ( <EOL> default = <NUM_LIT:0> , <EOL> verbose_name = _ ( '<STR_LIT>' ) , <EOL> editable = False ) <EOL> class Meta : <EOL> abstract = True <EOL> app_label = '<STR_LIT>' <EOL> verbose_name = _ ( '<STR_LIT>' ) <EOL> verbose_name_plural = _ ( '<STR_LIT>' ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> def get_absolute_url ( self ) : <EOL> return reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : self . slug } ) <EOL> def save ( self , * args , ** kwargs ) : <EOL> if not self . slug : <EOL> self . slug = slugify ( self . name ) <EOL> return super ( Badge , self ) . save ( * args , ** kwargs ) </s>
