def validate_inventory(cls, inventory): if not inventory: return 'You must add some merch to your inventory!' messages = [] for item_id, item in inventory.items(): quantity = int(item.get('quantity') or 0) if quantity <= 0 and cls.total_quantity(item) <= 0: messages.append('You must specify some quantity') for name, file in [(n, f) for (n, f) in item.items() if f]: match = cls._inventory_file_regex.match(name) if match and getattr(file, 'filename', None): file_type = match.group(1).upper() config_name = 'ALLOWED_INVENTORY_{}_EXTENSIONS'.format(file_type) extensions = getattr(c, config_name, []) ext = filename_extension(file.filename) if extensions and ext not in extensions: messages.append('{} files must be one of {}'.format(file_type.title(), ', '.join(extensions))) return '. '.join(uniquify([s.strip() for s in messages if s.strip()]))
def w9_extension(self): return filename_extension(self.w9_filename)
def stage_plot_extension(self): return filename_extension(self.filename)
def pic_extension(self): return filename_extension(self.pic_filename)