<s> """<STR_LIT>""" <EOL> import os <EOL> import uuid <EOL> from django . db import models <EOL> from django . db . models . signals import pre_delete <EOL> from django . dispatch import receiver <EOL> from django . utils import timezone <EOL> from jsonfield import JSONField <EOL> from omaha . models import BaseModel <EOL> from feedback . managers import FeedbackManager <EOL> def upload_to ( directory , obj , filename ) : <EOL> now = timezone . now ( ) <EOL> return os . path . join ( * map ( str , [ directory , now . year , now . month , <EOL> now . day , uuid . uuid4 ( ) , filename ] ) ) <EOL> def screenshot_upload_to ( obj , filename ) : <EOL> return upload_to ( '<STR_LIT>' , obj , filename ) <EOL> def blackbox_upload_to ( obj , filename ) : <EOL> return upload_to ( '<STR_LIT>' , obj , filename ) <EOL> def logs_upload_to ( obj , filename ) : <EOL> return upload_to ( '<STR_LIT>' , obj , filename ) <EOL> def attach_upload_to ( obj , filename ) : <EOL> return upload_to ( '<STR_LIT>' , obj , filename ) <EOL> class Feedback ( BaseModel ) : <EOL> description = models . TextField ( ) <EOL> email = models . CharField ( max_length = <NUM_LIT> , null = True , blank = True ) <EOL> page_url = models . CharField ( max_length = <NUM_LIT> , null = True , blank = True ) <EOL> screenshot = models . ImageField ( upload_to = screenshot_upload_to , blank = True , null = True ) <EOL> screenshot_size = models . PositiveIntegerField ( null = True , blank = True ) <EOL> blackbox = models . FileField ( upload_to = blackbox_upload_to , blank = True , null = True ) <EOL> blackbox_size = models . PositiveIntegerField ( null = True , blank = True ) <EOL> system_logs = models . FileField ( upload_to = logs_upload_to , blank = True , null = True ) <EOL> system_logs_size = models . PositiveIntegerField ( null = True , blank = True ) <EOL> attached_file = models . FileField ( upload_to = attach_upload_to , blank = True , null = True ) <EOL> attached_file_size = models . PositiveIntegerField ( null = True , blank = True ) <EOL> feedback_data = JSONField ( verbose_name = '<STR_LIT>' , help_text = '<STR_LIT>' , null = True , blank = True ) <EOL> ip = models . GenericIPAddressField ( blank = True , null = True ) <EOL> created_at = models . DateTimeField ( auto_now_add = True , db_index = True ) <EOL> updated_at = models . DateTimeField ( auto_now = True ) <EOL> objects = FeedbackManager ( ) <EOL> @ property <EOL> def size ( self ) : <EOL> return self . screenshot_size + self . blackbox_size + self . system_logs_size + self . attached_file_size <EOL> @ receiver ( pre_delete , sender = Feedback ) <EOL> def pre_feedback_delete ( sender , instance , ** kwargs ) : <EOL> file_fields = [ instance . screenshot , instance . blackbox , instance . system_logs , instance . attached_file ] <EOL> for field in file_fields : <EOL> storage , name = field . storage , field . name <EOL> if name : <EOL> storage . delete ( name ) </s>
