index
int64
repo_name
string
branch_name
string
path
string
content
string
import_graph
string
42,035,520
phtvo/yolo
refs/heads/master
/Yolov3/Model/yolov3.py
import os from collections import defaultdict import numpy as np import torch #from torch._C import device import torch.nn as nn from torch.autograd import Variable import torchvision.transforms as transforms from .headv3 import yoloHeadv3 import gdown path_to_sota = "https://drive.google.com/uc?id=1x9irVeBbcP09FtZWJMjlIPteZwxJgSzV" class skip_connection(nn.Module): def __init__(self): super(skip_connection, self).__init__() class yolov3(nn.Module): def __init__(self, model_name='yolov3', img_size=416, debug=False, classes=21, use_custom_config=False, lb_noobj=1.0, lb_obj=5.0, lb_class=2.0, lb_pos=1.0, use_focal_loss=False, device='cuda' ): super(yolov3, self).__init__() self.lb_noobj = lb_noobj self.lb_obj = lb_obj self.lb_class = lb_class self.lb_pos = lb_pos self.debug = debug self.pwd = os.path.dirname(__file__) if use_custom_config: self.layer_dict = self.get_config(use_custom_config) else: cfg = os.path.join(self.pwd, "yolov3.cfg") self.layer_dict = self.get_default_config(cfg, classes=classes) self.use_focal_loss = use_focal_loss self.device = device self.loss_names = ["x", "y", "w", "h", "object", "class", "recall", "precision"] self.seen = 0 self.header = np.array([0, 0, 0, self.seen, 0]) self.losses_log = [] self.model_name = model_name self.make_nn(debug=debug) ## check pretrained file files = os.listdir(self.pwd) if not 'yolov3.weights' in files: print('Download darknet sota weights') gdown.download(path_to_sota, os.path.join( self.pwd, 'yolov3.weights'), quiet=False) else: print('Already download pretrained weights') def make_conv(self, module, block, prev, it, debug=True): try: bn = int(block['batch_normalize']) bias = False except: bn = 0 bias = True f = int(block['filters']) s = int(block['stride']) ks = int(block['size']) pad = int((ks-1)//2) if int(block['pad']) else 0 conv = nn.Conv2d(prev, f, kernel_size=ks, padding=pad, stride=s, bias=bias) module.add_module(f'CONV2D_{it}', conv) if bn: module.add_module(f'BN_{it}', nn.BatchNorm2d(f)) act = block['activation'] if act == 'leaky': module.add_module(f'LeakyReLU_{it}', nn.LeakyReLU(0.1, inplace=True)) elif act == 'relu': module.add_module(f'ReLU_{it}', nn.ReLU(inplace=True)) if debug: print( f'Making conv_{it}, with f={f}, s={s}, ks={ks}, p={pad}, out: {f}') prev = f return f def make_upsample(self, module, block, prev, it, debug=True): s = int(block['stride']) if debug: print(f'Making upsample_{it} with scale_factor {s}') module.add_module(f'UPSAMPLE_{it}', nn.Upsample( scale_factor=s, mode='nearest')) return prev def make_route(self, module, block, prev, it, debug=True): route = block['layers'].split(',') start = int(route[0]) if len(route) > 1: end = int(route[1]) start = (it - start) if start > 0 else start end = (end - it) if end > 0 else end filters = self.output_filter[start] + self.output_filter[end] else: start = (it - start) if start > 0 else start filters = self.output_filter[start] module.add_module(f'ROUTE_{it}', skip_connection()) if debug: print(f'at it: {it} ROUTE {route}, filters = {filters}') return filters def make_shortcut(self, module, block, prev, it, debug=True): from_layer = int(block['from']) activation = block['activation'] if debug: print( f'make shortcut {it} from layer {from_layer} with activation {activation}') filters = prev # self.output_filter[it + from_layer] #self.output_filter[it] = filters if activation == 'linear': l = skip_connection() module.add_module(f'SHORTCUT_{it}', l) return filters def make_maxpool(self, module, layer, prev, it, debug): stride = int(layer['stride']) size = int(layer['size']) pad = int((size - 1) // 2) if debug: print(f'make MAXPOOL_{it} stride = {stride}, size = {size}') if size == 2 and stride == 1: # yolov3-tiny module.add_module(f'ZeroPad2d_{it}', nn.ZeroPad2d((0, 1, 0, 1))) #module.add_module(f'MAXPOOL_{it}', nn.MaxPool2d(stride=stride, kernel_size=size, padding=pad)) #else: module.add_module(f'MAXPOOL_{it}', nn.MaxPool2d( stride=stride, kernel_size=size, padding=pad)) return prev def make_yolo_layer(self, module, layer, prev, it, debug): mask = layer['mask'].split(',') anchor = layer['anchors'].split(',') masks = [int(each) for each in mask] anchors = [[int(anchor[i]), int(anchor[i+1])] for i in range(0, len(anchor), 2)] anchors = [anchors[i] for i in masks] num_classes = int(layer['classes']) num_anchors = int(layer['num']) yolo = yoloHeadv3(anchor=anchors, num_classes=num_classes, img_size=int( self.hyperparameters['width']), use_focal_loss=self.use_focal_loss, device=self.device, lb_noobj=self.lb_noobj, lb_obj=self.lb_obj, lb_class=self.lb_class, lb_pos=self.lb_pos) module.add_module(f"yolo_detection_{it}", yolo) if debug: print(f'make yolo layer with mask :{mask}, classes: {num_classes}') return prev def make_nn(self, debug=True): self.hyperparameters = self.layer_dict[0] # type:'net' self.output_filter = [] self.yolov3 = nn.ModuleList() prev_filter = int(self.hyperparameters['channels']) self.img_size = int(self.hyperparameters['width']) self.output_filter.append(prev_filter) for it, layer in enumerate(self.layer_dict[1:]): # first is net_info #print(layer) _type = layer['type'] module = nn.Sequential() if _type == 'convolutional': filters = self.make_conv(module, layer, prev_filter, it, debug) elif _type == 'maxpool': filters = self.make_maxpool( module, layer, prev_filter, it, debug) elif _type == 'upsample': filters = self.make_upsample( module, layer, prev_filter, it, debug) elif _type == 'route': filters = self.make_route( module, layer, prev_filter, it, debug) elif _type == 'shortcut': filters = self.make_shortcut( module, layer, prev_filter, it, debug) elif _type == 'yolo': filters = self.make_yolo_layer( module, layer, prev_filter, it, debug) else: raise Exception('UNKNOWN FORMAT') self.output_filter.append(filters) self.yolov3.append(module) prev_filter = filters if debug: print(self.yolov3) def forward(self, x, targets=None): is_training = targets is not None output = [] layer_output = [] if is_training: self.losses_log = [] count = 0 for i, (layer_dict, module) in enumerate(zip(self.layer_dict[1:], self.yolov3)): t = layer_dict['type'] if self.debug: print( f'we are at [{i}] th layer type[ {t}] with info {layer_dict}') if layer_dict['type'] in ['convolutional', 'upsample', 'maxpool']: x = module(x) elif layer_dict['type'] == 'route': layer = [int(item) for item in layer_dict['layers'].split(',')] x = torch.cat([layer_output[l] for l in layer], 1) # x = torch.cat([layer_output[-1], layer_output[layer[0]]]) elif layer_dict['type'] == 'shortcut': _from = int(layer_dict['from']) x = layer_output[-1] + layer_output[_from] elif layer_dict['type'] == 'yolo': if is_training: #x, *losses = module[0](x, targets) x, losses = module[0](x, targets) self.losses_log.append(losses) else: count += 1 if count: x = module(x) output.append(x) layer_output.append(x) return sum(output) if is_training else torch.cat(output, 1) def get_config(self, path): with open(path, 'r') as cfg: lines = cfg.read().split('\n') if self.debug: print(type(lines)) lines = [x for x in lines if len(x) > 0] lines = [x for x in lines if x[0] != '#'] lines = [x.rstrip().lstrip() for x in lines] block = {} blocks = [] for line in lines: if line[0] == "[": if len(block) != 0: blocks.append(block) block = {} block["type"] = line[1:-1].rstrip() else: key, value = line.split("=") block[key.rstrip()] = value.lstrip() blocks.append(block) return blocks def get_default_config(self, path, classes): with open(path, 'r') as cfg: lines = cfg.read().split('\n') if self.debug: print(type(lines)) lines = [x for x in lines if len(x) > 0] lines = [x for x in lines if x[0] != '#'] lines = [x.rstrip().lstrip() for x in lines] block = {} blocks = [] for line in lines: if line[0] == "[": if len(block) != 0: blocks.append(block) block = {} block["type"] = line[1:-1].rstrip() else: key, value = line.split("=") value = value.lstrip() if value == "$filters": value = str((classes + 5) * 3) elif value == "$classes": value = str(classes) block[key.rstrip()] = value.lstrip() blocks.append(block) return blocks def load_pretrained_by_num_class(self, path=None): print('load coco sota') sota = yolov3(classes=80) sota._load_weight(weights_path=os.path.join( self.pwd, 'yolov3.weights')) if path is None else sota._load_weight(path) sota_state_dict = sota.state_dict() model_state_dict = self.state_dict() layer_before_yolo = ['81', '93', '105'] for k, v in sota_state_dict.items(): _K = k.split('.')[1] t = 0 for l in layer_before_yolo: if l in _K: t += 1 if not t: model_state_dict.update({k: v}) self.load_state_dict(model_state_dict) def _load_weight(self, weights_path='yolov3.weights'): with open(weights_path, 'rb') as fw: header = np.fromfile(fw, dtype=np.int32, count=5) self.header = header self.seen = header[3] weights = np.fromfile(fw, dtype=np.float32) ptr = 0 for i, (layer_dict, module) in enumerate(zip(self.layer_dict[1:], self.yolov3)): if layer_dict['type'] == 'convolutional': conv_layer = module[0] #try: try: #if layer_dict["batch_normalize"]: xx = layer_dict["batch_normalize"] except: xx = 0 if xx: # Load BN bias, weights, running mean and running variance bn_layer = module[1] num_b = bn_layer.bias.numel() # Number of biases # Bias bn_b = torch.from_numpy( weights[ptr: ptr + num_b]).view_as(bn_layer.bias) bn_layer.bias.data.copy_(bn_b) ptr += num_b # Weight bn_w = torch.from_numpy( weights[ptr: ptr + num_b]).view_as(bn_layer.weight) bn_layer.weight.data.copy_(bn_w) ptr += num_b # Running Mean bn_rm = torch.from_numpy( weights[ptr: ptr + num_b]).view_as(bn_layer.running_mean) bn_layer.running_mean.data.copy_(bn_rm) ptr += num_b # Running Var bn_rv = torch.from_numpy( weights[ptr: ptr + num_b]).view_as(bn_layer.running_var) bn_layer.running_var.data.copy_(bn_rv) ptr += num_b #except: else: # Load conv. bias num_b = conv_layer.bias.numel() conv_b = torch.from_numpy( weights[ptr: ptr + num_b]).view_as(conv_layer.bias) conv_layer.bias.data.copy_(conv_b) ptr += num_b # Load conv. weights num_w = conv_layer.weight.numel() conv_w = torch.from_numpy( weights[ptr: ptr + num_w]).view_as(conv_layer.weight) conv_layer.weight.data.copy_(conv_w) ptr += num_w
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,521
phtvo/yolo
refs/heads/master
/Yolov3/Utils/args_train.py
import argparse def get_args(): parser = argparse.ArgumentParser() required = parser.add_argument_group('required arguments') optional = parser.add_argument_group('optional arguments') # freeze optional.add_argument('--fr', action='store_false', default=True, dest='freeze_backbone', help='freeze pretrained backbone (True)') # use pretrained optional.add_argument('--pre', action='store_true', default=False, dest='use_pretrained', help='use pretrained (False)') # continue trainig optional.add_argument('--con', action='store_false', default=True, dest='to_continue', help='not continue training ') # custom config optional.add_argument('--cfg', action='store', default='default', type=str, dest='cfg', help='use custom config, if use, pass the path of custom cfg file, default is (./config/yolov3.cfg) ') # number of class optional.add_argument('--ncl', action='store', default=21, type=int, dest='num_class', help='number of annot classes (21)') # number of class optional.add_argument('--sch', action='store_true', default=False, dest='use_scheduler', help='set it to turn on using scheduler (False)') # @@ path to voc data required.add_argument('--data', action='store', default=None, dest='data', required=True, help='path to voc data folder') # @@ path to voc labels required.add_argument('--lb', action='store', default=None, dest='labels', required=False, help='path to labels') # @@ split ratio of voc data optional.add_argument('--split', action='store', default=None, type=float, dest='split', required=False, help='split ratio [0., 1.] of voc dataset (None) if not None') # batch size (8) optional.add_argument('--bs', action='store', default=8, type=int, dest='batch_size', help='number of batch size (8)') # number of workers (0) optional.add_argument('--nw', action='store', default=0, type=int, dest='num_worker', help='number of worker (0)') # optim type optional.add_argument('--op', action='store', default="sgd", type=str, choices=['sgd', 'adam'], dest='optim', help='type of optimizer: sgd/adam (sgd)') # momentum for sgd optional.add_argument('--mo', action='store', default=0.91, type=float, dest='momentum', help='Momentum for sgd (0.91)') # learning rate optional.add_argument('--lr', action='store', default=0.01, type=float, dest='lr', help='learning rate (0.01)') # weight decay optional.add_argument('--wd', action='store', default=1e-4, type=float, dest='wd', help='weight decay (1e-4)') # epoch optional.add_argument('--ep', action='store', default=20, type=int, dest='epoch', help='number of epoch (20)') # use cuda optional.add_argument('--cpu', action='store_true', default=False, dest='use_cpu', help='use cpu or not (False)') # log path optional.add_argument('--log', action='store', default="checkpoint", type=str, dest='log_path', help='path to save chkpoint and log (./checkpoint)') # lambda Objectness optional.add_argument('--lo', action='store', default=2.0, type=float, dest='lb_obj', help='lambda objectness lossfunciton (2.0)') # lambda NoObj optional.add_argument('--lno', action='store', default=0.5, type=float, dest='lb_noobj', help='lambda objectless lossfunciton (0.5)') # lambda position optional.add_argument('--lpo', action='store', default=1.0, type=float, dest='lb_pos', help='lambda position lossfunciton (1.)') # lambda class optional.add_argument('--lcl', action='store', default=1.0, type=float, dest='lb_clss', help='lambda class lossfunciton (1.)') # use focal loss function optional.add_argument('--focal', action='store_true', default=False, dest='use_focal_loss', help='use focal loss in clasification (false)') args = parser.parse_args() return args
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,522
phtvo/yolo
refs/heads/master
/setup.py
from setuptools import setup, find_packages with open('./Yolov3/requirements.txt') as f: required = f.read().splitlines() setup( name='Yolov3', version='1.0', description='', author='HugPhat', author_email='hug.phat.vo@gmail.com', license="MIT", packages=find_packages(), # same as name include_package_data=True, install_requires=[ required ], #external packages as dependencies scripts=[ ], python_requires='>=3.6', )
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,523
phtvo/yolo
refs/heads/master
/Yolov3/Dataset/data_argument.py
import random import cv2 import numpy as np import imgaug as ia import imgaug.augmenters as iaa from imgaug.augmentables.bbs import BoundingBox, BoundingBoxesOnImage class custom_aug: def __init__(self) -> None: # Sometimes(0.5, ...) applies the given augmenter in 50% of all cases, # e.g. Sometimes(0.5, GaussianBlur(0.3)) would blur roughly every second image. def sometimes(aug): return iaa.Sometimes(0.5, aug) self.main_seq = iaa.Sequential( [ # apply the following augmenters to most images iaa.Fliplr(0.5), # horizontally flip 50% of all images iaa.Flipud(0.15), # vertically flip 20% of all images # crop images by -5% to 10% of their height/width sometimes(iaa.CropAndPad( percent=(0, 0.15), pad_mode=ia.ALL, pad_cval=(0, 255) )), sometimes(iaa.Affine( # scale images to 80-120% of their size, individually per axis scale={"x": (0.5, 1.3), "y": (0.5, 1.5)}, # translate by -20 to +20 percent (per axis) translate_px={"x": (-10, 10), "y": (-10, 10) }, #translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)}, rotate=(-30, 30), # rotate by -45 to +45 degrees shear=(-25, 25), # shear by -16 to +16 degrees # use nearest neighbour or bilinear interpolation (fast) order=[0, 1], # if mode is constant, use a cval between 0 and 255 cval=(0, 255), # use any of scikit-image's warping modes (see 2nd image from the top for examples) mode=ia.ALL )), # execute 0 to 5 of the following (less important) augmenters per image # don't execute all of them, as that would often be way too strong iaa.SomeOf((0, 5), [ # convert images into their superpixel representation #sometimes(iaa.Superpixels( # p_replace=(0, 1.0), n_segments=(20, 100))), iaa.OneOf([ # blur images with a sigma between 0 and 3.0 iaa.GaussianBlur((0.9, 1.0)), # blur image using local means with kernel sizes between 2 and 7 #iaa.AverageBlur(k=(1, 3)), # blur image using local medians with kernel sizes between 2 and 7 #iaa.MedianBlur(k=(1, 3)), ]), #iaa.Emboss(alpha=(0.4, 0.8), strength=( # 0.4, 0.8)), # emboss images # search either for all edges or for directed edges, # blend the result with the original image using a blobby mask iaa.SimplexNoiseAlpha(iaa.OneOf([ iaa.EdgeDetect(alpha=(0.1, .5)), iaa.DirectedEdgeDetect(alpha=(0.1, .50), direction=(0.90, 1.0)), ])), # add gaussian noise to images iaa.AdditiveGaussianNoise(loc=0, scale=( 0.0, 0.05*255), per_channel=0.5), # invert color channels #iaa.Invert(1, per_channel=True), # change brightness of images (by -10 to 10 of original value) iaa.Add((0.8, .1), per_channel=0.5), # change hue and saturation iaa.AddToHueAndSaturation((0, 1)), # either change the brightness of the whole image (sometimes # per channel) or change the brightness of subareas iaa.OneOf([ #iaa.Multiply((0.8, 1.1), per_channel=0.5), iaa.FrequencyNoiseAlpha( exponent=(-2, 0), first=iaa.Multiply((0.6, 1.), per_channel=True), #second=iaa.LinearContrast((0.6, 1.0)) ) ]), # improve or worsen the contrast #iaa.LinearContrast((0.1, .60), per_channel=0.5), #iaa.Grayscale(alpha=(0.1, .5)), # move pixels locally around (with random strengths) #sometimes(iaa.ElasticTransformation( # alpha=(0.7, 1), sigma=0.1)), # sometimes move parts of the image around #sometimes(iaa.PiecewiseAffine(scale=(0.01, 0.05))), #sometimes(iaa.PerspectiveTransform(scale=(0.1, 0.5))) ], random_order=True ) ], random_order=True ) def to_imgaug_format(self, bboxes: list, names: list, shape:list) -> BoundingBoxesOnImage: bbox_on_image = [] for n, bbox in zip(names, bboxes): x1, y1, x2, y2 = bbox bbox_on_image.append(BoundingBox(x1, y1, x2, y2, n)) bbs = BoundingBoxesOnImage(bbox_on_image, shape=shape) return bbs def to_numpy(self, bbs)->np.ndarray: res = [] _name = [] for each in bbs.bounding_boxes: res.append([each.x1, each.y1, each.x2, each.y2]) _name.append(each.label) if res == []: print('*'*20) print('*'*20) res = [[0.,0.,0.,0.]] _name = [0.] return np.asarray(res), _name def __call__(self, image: np.ndarray, bboxes:list, names:list)->list: bbs = self.to_imgaug_format(bboxes, names, image.shape) images_aug, bbs_aug = self.main_seq(image=image, bounding_boxes=bbs) clipped_bbs = bbs_aug.remove_out_of_image().clip_out_of_image() bbox, lb = self.to_numpy(clipped_bbs) return images_aug, bbox, lb class RandomShear(object): def __init__(self, shear_factor=0.2): self.shear_factor = shear_factor if type(self.shear_factor) == tuple: assert len( self.shear_factor) == 2, "Invalid range for scaling factor" else: self.shear_factor = (-self.shear_factor, self.shear_factor) shear_factor = random.uniform(*self.shear_factor) def __call__(self, img, bboxes): shear_factor = random.uniform(*self.shear_factor) w, h = img.shape[1], img.shape[0] if shear_factor < 0: img, bboxes = HorizontalFlip()(img, bboxes) M = np.array([[1, abs(shear_factor), 0], [0, 1, 0]]) nW = img.shape[1] + abs(shear_factor*img.shape[0]) bboxes[:, [0, 2]] += ((bboxes[:, [1, 3]]) * abs(shear_factor)).astype(int) img = cv2.warpAffine(img, M, (int(nW), img.shape[0])) if shear_factor < 0: img, bboxes = HorizontalFlip()(img, bboxes) img = cv2.resize(img, (w, h)) scale_factor_x = nW / w bboxes[:, :4] /= [scale_factor_x, 1, scale_factor_x, 1] return img, bboxes class Shear(object): def __init__(self, shear_factor=0.2): self.shear_factor = shear_factor def __call__(self, img, bboxes): w, h = img.shape[:2] shear_factor = self.shear_factor if shear_factor < 0: img, bboxes = HorizontalFlip()(img, bboxes) M = np.array([[1, abs(shear_factor), 0], [0, 1, 0]]) nW = img.shape[1] + int(abs(shear_factor*img.shape[0])) bboxes[:, [0, 2]] += ((bboxes[:, [1, 3]]) * abs(shear_factor)).astype(int) img = cv2.warpAffine(img, M, (w, img.shape[0])) if shear_factor < 0: img, bboxes = HorizontalFlip()(img, bboxes) print(f'(shear)--> new {bboxes}') bboxes = clip_box(bboxes, [0, 0, w, h], 0) print(f'--> clipped {bboxes}') return img, bboxes class HorizontalFlip(object): def __init__(self): pass def __call__(self, img, bboxes): img_center = np.array(img.shape[:2])[::-1]/2 img_center = np.hstack((img_center, img_center)) img = img[:, ::-1, :] bboxes[:, [0, 2]] += 2*(img_center[[0, 2]] - bboxes[:, [0, 2]]) box_w = abs(bboxes[:, 0] - bboxes[:, 2]) bboxes[:, 0] -= box_w bboxes[:, 2] += box_w return img, bboxes def bbox_area(bbox): return (bbox[:, 2] - bbox[:, 0])*(bbox[:, 3] - bbox[:, 1]) def clip_box(bbox, clip_box, alpha): ar_ = (bbox_area(bbox)) x_min = np.maximum(bbox[:, 0], clip_box[0]).reshape(-1, 1) y_min = np.maximum(bbox[:, 1], clip_box[1]).reshape(-1, 1) x_max = np.minimum(bbox[:, 2], clip_box[2]).reshape(-1, 1) y_max = np.minimum(bbox[:, 3], clip_box[3]).reshape(-1, 1) bbox = np.hstack((x_min, y_min, x_max, y_max, bbox[:, 4:])) return bbox def get_enclosing_box(corners): x_ = corners[:, [0, 2, 4, 6]] y_ = corners[:, [1, 3, 5, 7]] xmin = np.min(x_, 1).reshape(-1, 1) ymin = np.min(y_, 1).reshape(-1, 1) xmax = np.max(x_, 1).reshape(-1, 1) ymax = np.max(y_, 1).reshape(-1, 1) final = np.hstack((xmin, ymin, xmax, ymax, corners[:, 8:])) return final def rotate_im(image, angle): (h, w) = image.shape[:2] (cX, cY) = (w // 2, h // 2) M = cv2.getRotationMatrix2D((cX, cY), angle, 1.0) cos = np.abs(M[0, 0]) sin = np.abs(M[0, 1]) # compute the new bounding dimensions of the image nW = int((h * sin) + (w * cos)) nH = int((h * cos) + (w * sin)) # adjust the rotation matrix to take into account translation M[0, 2] += (nW / 2) - cX M[1, 2] += (nH / 2) - cY image = cv2.warpAffine(image, M, (nW, nH)) return image def get_corners(bboxes): width = (bboxes[:, 2] - bboxes[:, 0]).reshape(-1, 1) height = (bboxes[:, 3] - bboxes[:, 1]).reshape(-1, 1) x1 = bboxes[:, 0].reshape(-1, 1) y1 = bboxes[:, 1].reshape(-1, 1) x2 = x1 + width y2 = y1 x3 = x1 y3 = y1 + height x4 = bboxes[:, 2].reshape(-1, 1) y4 = bboxes[:, 3].reshape(-1, 1) corners = np.hstack((x1, y1, x2, y2, x3, y3, x4, y4)) return corners def rotate_box(corners, angle, cx, cy, h, w): corners = corners.reshape(-1, 2) corners = np.hstack( (corners, np.ones((corners.shape[0], 1), dtype=type(corners[0][0])))) M = cv2.getRotationMatrix2D((cx, cy), angle, 1.0) cos = np.abs(M[0, 0]) sin = np.abs(M[0, 1]) nW = int((h * sin) + (w * cos)) nH = int((h * cos) + (w * sin)) M[0, 2] += (nW / 2) - cx M[1, 2] += (nH / 2) - cy calculated = np.dot(M, corners.T).T calculated = calculated.reshape(-1, 8) return calculated class Rotate(object): def __init__(self, angle): ''' Input: angle-> list/tuple: range of angle [num, num2] ''' self.angle = angle def __call__(self, img, bboxes): ''' * Input: + img-> np.ndarray + bboxes-> np.ndarray ''' angle = self.angle w, h = img.shape[1], img.shape[0] cx, cy = w//2, h//2 corners = get_corners(bboxes) corners = np.hstack((corners, bboxes[:, 4:])) img = rotate_im(img, angle) corners[:, :8] = rotate_box(corners[:, :8], angle, cx, cy, h, w) new_bbox = get_enclosing_box(corners) scale_factor_x = img.shape[1] / w scale_factor_y = img.shape[0] / h img = cv2.resize(img, (w, h)) new_bbox[:, :4] /= [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y] bboxes = new_bbox print(f'(Rotate) --> new {bboxes}') bboxes = clip_box(bboxes, [0, 0, w, h], 0) print(f'--> clipped {bboxes}') return img, bboxes def scale(img, boxes, scale): h, w, _ = img.shape img = cv2.resize(img, dsize=( int(w * scale), int(h*scale)), interpolation=cv2.INTER_LINEAR) for i in range(2): boxes[:, i] = boxes[:, i] * scale boxes[:, i+2] = boxes[:, i+2] * scale return img, boxes def random_rotate(img, boxes): a = random.uniform(-30, 30) return Rotate(a)(img, boxes) def random_shear(img, boxes): a = random.uniform(-0.2, 0.2) return Shear(a)(img, boxes) def random_scale(img, boxes): scale = [random.uniform(0.8, 1.2), random.uniform(0.8, 1.2)] h, w, _ = img.shape img = cv2.resize(img, dsize=( int(w * scale[0]), int(h*scale[1])), interpolation=cv2.INTER_LINEAR) for i in range(2): boxes[:, i] = boxes[:, i] * scale[i] boxes[:, i+2] = boxes[:, i+2] * scale[i] return img, boxes def random_blur(bgr): ksize = random.choice([2, 3, 4, 5]) bgr = cv2.blur(bgr, (ksize, ksize)) return bgr def random_brightness(bgr): hsv = cv2.cvtColor(bgr, cv2.COLOR_BGR2HSV) h, s, v = cv2.split(hsv) adjust = random.uniform(0.8, 1.2) v = v * adjust v = np.clip(v, 0, 255).astype(hsv.dtype) hsv = cv2.merge((h, s, v)) bgr = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) return bgr def random_hue(bgr): hsv = cv2.cvtColor(bgr, cv2.COLOR_BGR2HSV) h, s, v = cv2.split(hsv) adjust = random.uniform(0.8, 1.2) h = h * adjust h = np.clip(h, 0, 255).astype(hsv.dtype) hsv = cv2.merge((h, s, v)) bgr = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) return bgr def random_saturation(bgr): hsv = cv2.cvtColor(bgr, cv2.COLOR_BGR2HSV) h, s, v = cv2.split(hsv) adjust = random.uniform(0.5, 1.5) s = s * adjust s = np.clip(s, 0, 255).astype(hsv.dtype) hsv = cv2.merge((h, s, v)) bgr = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) return bgr def random_HFlip(img, bbox): center = np.array(img.shape[:2])[::-1] / 2 center = np.hstack((center, center)) img = img.copy()[:, ::-1, :] bbox[:, [0, 2]] = 2*center[[0, 2]] - bbox[:, [0, 2]] box_w = abs(bbox[:, 0] - bbox[:, 2]) bbox[:, 0] -= box_w bbox[:, 2] += box_w return img, bbox def random_VFlip(img, bbox): center = np.array(img.shape[:2])[::-1] / 2 center = np.hstack((center, center)) img = img.copy()[::-1, :, :] bbox[:, [1, 3]] = 2*center[[1, 3]] - bbox[:, [1, 3]] box_w = abs(bbox[:, 1] - bbox[:, 3]) bbox[:, 1] -= box_w bbox[:, 3] += box_w return img, bbox
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,524
phtvo/yolo
refs/heads/master
/Experiments/simple/debug_network.py
import torch import torch.optim as optim from torch.utils.data import DataLoader import sys import os sys.path.insert(0, os.getcwd()) PATH = os.path.dirname(__file__) from Yolov3.Model.yolov3 import yolov3 as yolo from Yolov3.Utils.train_module import train_module from simple_data import simple_data as dataSet model = yolo(classes=2, use_custom_config=False, lb_obj=1, lb_class=1, lb_noobj=0) path_to_data = r'E:\ProgrammingSkills\python\DEEP_LEARNING\DATASETS\simple_obj_detection\cat_dog' trainLoader = DataLoader(dataSet(path=path_to_data, labels=['cat', 'dog'], max_objects=3, split=0.02, debug=False, draw=False, argument=True, is_train=True), batch_size=8, shuffle=True, num_workers=0, drop_last=False ) valLoader = DataLoader(dataSet(path=path_to_data, labels=['cat', 'dog'], max_objects=3, split=0.9, debug=False, draw=False, argument=False, is_train=False), batch_size=8, shuffle=True, num_workers=0, drop_last=False ) optimizer = optim.SGD(model.parameters(), lr=0.001, momentum=0.92, weight_decay=5e-4) train_module( model=model, trainLoader=trainLoader, valLoader=valLoader, optimizer_name='sgd', optimizer=optimizer, lr_scheduler=None, warmup_scheduler=None, Epochs=10, use_cuda= False, writer=None, path=None, lr_rate=0.001, wd=5e-5, momen=0.92, start_epoch=1 )
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,525
phtvo/yolo
refs/heads/master
/Experiments/simple/train.py
import sys import os File_Path = os.getcwd() sys.path.append(File_Path) sys.path.insert(0, os.path.join(os.getcwd(), '../..')) #sys.path.insert(1, File_Path) from Yolov3.Utils.train import template_dataLoaderFunc, train from simple_data import readTxt, simple_data def loadData(args): labels = readTxt(os.path.join(File_Path, 'config', 'class.names')) labels.pop(-1) return template_dataLoaderFunc(simple_data, args, labels) if __name__ == "__main__": print('Initilizing..') train( File_Path, loadData )
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,526
phtvo/yolo
refs/heads/master
/Experiments/voc2012/visualize_data.py
import sys import os sys.path.insert(0, os.getcwd()) PATH = os.path.dirname(__file__) import cv2 import matplotlib.pyplot as plt from Yolov3.Dataset.dataformat import ReadXML_VOC_Format, readTxt is_train = True path = r"E:\ProgrammingSkills\python\DEEP_LEARNING\DATASETS\PASCALVOC\VOCdevkit\VOC2012" train_txt = 'ImageSets/Main/train.txt' val_txt = 'ImageSets/Main/val.txt' annotations = "Annotations" jpegimages = "JPEGImages" def Init(): images_path = train_txt if (is_train) else val_txt images_path = readTxt(os.path.join(path, images_path)) images_path.pop(-1) # rawdata format: [path_2_image, path_2_xml] rawData = list() for each in images_path: xml = os.path.join(path, annotations, each + '.xml') jpeg = os.path.join(path, jpegimages, each + '.jpg') rawData.append([jpeg, xml]) return rawData def visualize_all(): rawData = Init() for (path_2_image, path_2_xml) in rawData: bboxes, fname = ReadXML_VOC_Format(path_2_xml) image = cv2.imread(path_2_image) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) for d in (bboxes): name, x1, y1, x2, y2 = d cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 255), 2, 1) cv2.putText(image, str(name), (x1+10, y1+10 ), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 2) plt.imshow(image) plt.show() def amount_obj_per_class(): import json rawData = Init() labels = readTxt(r'Experiments\voc2012\config\class.names') labels.pop(-1) object_per_class = {'objects' : None} object_per_class['objects'] = {k: 0 for k in labels} print(object_per_class) object_per_class.update({'sum' : 0}) bbox_sizes = {'w' : [], 'h' : []} for (path_2_image, path_2_xml) in rawData: bboxes, fname = ReadXML_VOC_Format(path_2_xml) for d in (bboxes): name, x1, y1, x2, y2 = d # object_per_class['objects'][name] += 1 object_per_class['sum'] += 1 # bbox_sizes['w'].append( x2 - x1 ) bbox_sizes['h'].append( y2 - y1 ) # path = r'Experiments\voc2012\config' with open(os.path.join(path, 'objects.json'), 'w') as f : json.dump(object_per_class, f, sort_keys=True, indent=4) with open(os.path.join(path, 'bboxes.json'), 'w') as f: json.dump(bbox_sizes, f, sort_keys=True, indent=4) if __name__ == '__main__': #visualize_all() amount_obj_per_class()
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,527
phtvo/yolo
refs/heads/master
/Yolov3/Utils/train_module.py
import numpy as np import os import torch import torch.nn as nn import torch.optim as optim from torch.autograd import Variable from torch.optim import lr_scheduler from torch.utils.data import DataLoader from torchvision import datasets from torchvision import transforms from tqdm import tqdm def save_model(name, model, optimizer, path, epoch, optim_name, lr_rate,wd,m, lr_scheduler): checkpoint = { 'epoch': epoch + 1, 'state_dict': model.state_dict(), 'optimizer': optimizer.state_dict(), 'optimizer_name': optim_name, 'lr': lr_rate, 'wd': wd, 'm':m, 'sche': lr_scheduler.state_dict() if lr_scheduler else None, } path = os.path.join(path, name) torch.save(checkpoint, path) def unpack_data_loss_function(loss_accumulate, loss, writer, batch_index,checkpoint_index, mode, print_now:bool, epoch): """Accumulate loss value if variable exist else create dict element of [loss_accumulate] || Unpack precision || Write loss values to tensorboard Args: loss_accumulate ([dict]): [dictionary of all loss values] loss ([dict]): [loss values passing to loss function] writer ([SummaryWriter]): [tensorboard writer object] checkpoint_index ([int]): [checkpoint_index of update round] mode ([str]): [train or val] print_now([bool]): [execute print log] Returns: loss_accumulate([dict]) : [change of loss_accumulate] """ ## if loss_accumulate =={}: keys = list(loss[0].keys()) for key in keys: loss_accumulate.update({key : []}) for order, layer in enumerate(loss): for (k, v) in loss_accumulate.items(): try: loss_accumulate[k][order] += layer[k] except: loss_accumulate[k].insert(order, layer[k]) desc = "" for (k, v) in loss_accumulate.items(): temp = {} if not k in ['loss_x', 'loss_y', 'loss_w', 'loss_h']: desc += '|' + str(k) + ": " + str(round(sum(v)/ (batch_index * len(v)), 3)) for i, each in enumerate(v): #desc += str(each/batch_index) + " |" temp.update({'layer_' + str(i) : each/batch_index}) if print_now: if writer: if mode == 'val': writer.add_scalar(k + '_layer_' + str(i) + "/" + mode , each/ batch_index, epoch) else: writer.add_scalar( k + '_layer_' + str(i) + "/" + mode, each / batch_index, checkpoint_index) else: pass return loss_accumulate, desc def train_module( model, # yolov3 trainLoader: DataLoader, # train: DataLoader valLoader : DataLoader, # val: DataLoader optimizer_name:str, # optimizer : optim, # optimizer lr_scheduler: optim.lr_scheduler, warmup_scheduler , writer, # tensorboard logger use_cuda: bool, Epochs : int, path:str, lr_rate:float, wd:float,# weightdecay momen:float, start_epoch=1, ): """Template Train function Args: \n model (yolov3): pre defined yolov3 model \n trainLoader(Dataloader) \n valLoader(Dataloader) \n optimizer(torch.optim) \n lr_scheduler \n Epochs (int): number of epoch \n use_cuda (bool): use cuda (gpu) or not \n path (str) : path to save model checkpoint Returns: type: description """ #accuracy_array = [] #recall_array = [] #precision_array = [] best_loss_value = 1000 best_current_model = 'best_model.pth' if use_cuda: FloatTensor = torch.cuda.FloatTensor #model.cuda() else: FloatTensor = torch.FloatTensor for epoch in range(start_epoch, Epochs + 1): model.train() loss_value = 0 loss_accumulate = {} #loss, lossX, lossY, lossW, lossH, lossConfidence, lossClass, recall, precision = 0, 0, 0, 0, 0, 0, 0, 0, 0 with tqdm(total = len(trainLoader)) as epoch_pbar: epoch_pbar.set_description(f'[Train] Epoch {epoch}') for batch_index, (input_tensor, target_tensor) in enumerate(trainLoader): input_tensor = input_tensor.type(FloatTensor) target_tensor = target_tensor.type(FloatTensor) # zero grads optimizer.zero_grad() output = model(input_tensor, target_tensor) # return loss if torch.isinf(output).any() or torch.isnan(output).any(): print(f'inp max {torch.max(input_tensor)} | min {torch.min(input_tensor)}') print(f'tar max {torch.max(target_tensor)} | min {torch.min(target_tensor)}') loss_value += output.item()/3 checkpoint_index = (epoch -1)*len(trainLoader) + batch_index write_now = (checkpoint_index + 1) % 1 == 0 ## 1-> 20 loss_accumulate, desc = unpack_data_loss_function( loss_accumulate, model.losses_log, writer, batch_index + 1, checkpoint_index, 'train', write_now, epoch) #print(loss_accumulate['total']) description = f'[Train: {epoch}/{Epochs} Epoch]:[{desc}]' epoch_pbar.set_description(description) epoch_pbar.update(1) output.backward() optimizer.step() if lr_scheduler: lr_scheduler.step(epoch) if warmup_scheduler: warmup_scheduler.step(epoch) loss_accumulate = {} model.eval() with tqdm(total=len(valLoader)) as epoch_pbar: epoch_pbar.set_description(f'[Validate] Epoch {epoch}') for batch_index, (input_tensor, target_tensor) in enumerate(valLoader): input_tensor = input_tensor.type(FloatTensor) target_tensor = target_tensor.type(FloatTensor) # return dictionary with torch.no_grad(): output = model(input_tensor, target_tensor) # return loss checkpoint_index = (epoch -1)*len(valLoader) + batch_index write_now = (batch_index + 1) == len(valLoader) loss_accumulate, desc = unpack_data_loss_function( loss_accumulate, model.losses_log, writer, batch_index + 1, checkpoint_index, 'val', write_now, epoch) description = f'[Validate: {epoch}/{Epochs} Epoch]:[{desc}]' epoch_pbar.set_description(description) epoch_pbar.update(1) total= sum(loss_accumulate['total']) / (len(valLoader)) if total < best_loss_value: if not path is None: save_model(model=model, path=path, name=best_current_model, epoch=epoch, optimizer=optimizer, optim_name=optimizer_name, lr_rate=lr_rate, wd=wd, m=momen, lr_scheduler=lr_scheduler) if not path is None: save_model(model=model, path=path, name="current_checkpoint.pth", epoch=epoch, optimizer=optimizer, optim_name=optimizer_name, lr_rate=lr_rate, wd=wd, m=momen, lr_scheduler=lr_scheduler)
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,528
phtvo/yolo
refs/heads/master
/Yolov3/Utils/create_model.py
import sys import os sys.path.insert(0, os.getcwd()) PATH = os.path.dirname(__file__) import torch from Yolov3.Model.yolov3 import yolov3 def create_model(num_classes, default_cfg:str = None , lb_noobj = 1.0, lb_obj=5.0, lb_class=2.0, lb_pos=1.0, device='cuda', use_focal_loss=False ): """[Create yolo model] Args: num_classes (int): [number of class when using default config] default_cfg (str, None): [path to custom config]. Defaults to None. Returns: [yolov3]: [model yolo] """ if not default_cfg: return yolov3(classes= num_classes, lb_noobj=lb_noobj, lb_obj=lb_obj, lb_class=lb_class, lb_pos=lb_pos, device=device, use_focal_loss=use_focal_loss ).to(device=device) else: return yolov3(use_custom_config=default_cfg, lb_noobj=lb_noobj, lb_obj=lb_obj, lb_class=lb_class, lb_pos=lb_pos, device=device, use_focal_loss=use_focal_loss ).to(device=device)
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,529
phtvo/yolo
refs/heads/master
/Yolov3/Dataset/dataformat.py
import os import json import numpy as np import xml.etree.cElementTree as ET class COCO: def __init__(self, path_to_annot, path_to_images=None) -> None: self.path_to_images = path_to_images self.Init(path_to_annot) def Init(self, path_to_annot): self.images = {} self.classes_names = {} # load json with open(path_to_annot, 'r') as f: data = json.load(f) #process class names for each in data["categories"]: id = each["id"] each.pop("id") self.classes_names.update({id: each}) # get image info by id for each in data["images"]: image_id = each["id"] each.pop("id") if self.path_to_images: each["file_name"] = os.path.join( self.path_to_images, each["file_name"]) self.images.update({image_id: each}) # add annot to images for each in data["annotations"]: image_id = each["image_id"] cat_id = each["category_id"] each.update({"class": self.classes_names[cat_id]}) each.pop("image_id") try: self.images[image_id]["annots"].append(each) except: self.images[image_id].update({"annots": []}) self.images[image_id]["annots"].append(each) def __len__(self): return len(self.images) def __iter__(self): for k, v in self.images.items(): yield (k, v) def __getitem__(self, index) -> dict: try: data = self.images[index] except KeyError: print("Key Error : {}".format(index)) data = None return data def readTxt(path): with open(path, 'r') as f: data = f.read() return data.split('\n') def ReadXML_VOC_Format(path:str): """ Read .XML annotation file with VOC Format Return: list [[class_name, x1, y1, x2, y2],...] Args: path (str): path to xml file """ tree = ET.parse(path) root = tree.getroot() list_with_all_boxes = [] for boxes in root.iter('object'): filename = root.find('filename').text ymin, xmin, ymax, xmax = None, None, None, None class_name = boxes.find('name').text for box in boxes.findall("bndbox"): ymin = int(box.find("ymin").text) xmin = int(box.find("xmin").text) ymax = int(box.find("ymax").text) xmax = int(box.find("xmax").text) list_with_single_boxes = [class_name, xmin, ymin, xmax, ymax] list_with_all_boxes.append(list_with_single_boxes) return list_with_all_boxes, filename def COCO_Format(path_to_annot, path_to_images=None): """ Read Annotation Args: path_to_annot ([str]): [path to annotation] path_to_images ([str]): [path to images folder] """ return COCO(path_to_annot, path_to_images)
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,530
phtvo/yolo
refs/heads/master
/Test/test_dataset.py
from __future__ import absolute_import from Yolov3.Datasets.dataset import yoloCoreDataset
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,035,531
phtvo/yolo
refs/heads/master
/Yolov3/Utils/train.py
import sys import os import shutil from datetime import datetime pwd_path = os.getcwd() sys.path.insert(0, os.path.join(os.getcwd(), '../..')) #sys.path.insert(1, pwd_path) import numpy as np import torch import torch.optim as optim from torch.autograd import Variable from torch.utils.data import DataLoader from torchvision import datasets from torchvision import transforms from torch.utils.tensorboard import SummaryWriter from Yolov3.Utils.train_module import train_module import pytorch_warmup as warmup from warmup_scheduler import GradualWarmupScheduler torch.autograd.set_detect_anomaly(True) from Yolov3.Utils.args_train import get_args from Yolov3.Dataset.dataset import yoloCoreDataset from Yolov3.Utils.create_model import create_model # logger callback: def create_writer(log_saving_path): writer = SummaryWriter(log_dir=log_saving_path) print(f'Log file is saved at <{log_saving_path}>') #logfile = open(os.path.join(log_dir, 'log.txt'), 'w') return writer def template_dataLoaderFunc(dataSet: yoloCoreDataset, args, labels): if labels is None: with open(args.labels, 'r') as f: labels = f.data() labels.pop(-1) trainLoader = DataLoader(dataSet(path=args.data, labels=labels, max_objects=18, split=args.split, debug=False, draw=False, argument=True, is_train=True), batch_size=args.batch_size, shuffle=True, num_workers=args.num_worker, drop_last=False ) # dont use img augment for val valLoader = DataLoader(dataSet(path=args.data, labels=labels, max_objects=18, split=args.split, debug=False, draw=False, argument=False, is_train=False), batch_size=args.batch_size, shuffle=True, num_workers=args.num_worker, drop_last=False ) return trainLoader, valLoader def train( pwd_path, dataLoaderFunc, # callback returns [trainLoader, valLoader] modelLoaderFunc=None, # callback load different architect model ): ###### handle args ######### args = get_args() ############################ trainLoader, valLoader = dataLoaderFunc(args) print('Succesfully load dataset') num_steps = len(trainLoader) * args.epoch lr_scheduler = None warmup_scheduler = None ############### Loading Model #################### device = 'cuda' if not args.use_cpu else 'cpu' if not args.cfg and modelLoaderFunc is None: print(f'Succesfully load model with default config') yolo = create_model(num_classes=args.num_class, lb_noobj=args.lb_noobj, lb_obj=args.lb_obj, lb_class=args.lb_clss, lb_pos=args.lb_pos, device=device, use_focal_loss=args.use_focal_loss ) elif args.cfg == 'default': f = os.path.join(pwd_path, 'config', 'yolov3.cfg') print(f"Succesfully load model with custom config at '{f}' ") yolo = create_model(None, default_cfg=f, lb_noobj=args.lb_noobj, lb_obj=args.lb_obj, lb_class=args.lb_clss, lb_pos=args.lb_pos, device=device, use_focal_loss=args.use_focal_loss ) else: print(f"Succesfully load model with custom config at '{args.cfg}' ") yolo = create_model(None, default_cfg=args.cfg, lb_noobj=args.lb_noobj, lb_obj=args.lb_obj, lb_class=args.lb_clss, lb_pos=args.lb_pos, device=device, use_focal_loss=args.use_focal_loss ) if not modelLoaderFunc is None: print('Load new architect with yoloHead ..') yolo = modelLoaderFunc( lb_noobj = args.lb_noobj, lb_obj = args.lb_obj, lb_class = args.lb_clss, lb_pos = args.lb_pos, device=device, use_focal_loss=args.use_focal_loss ) print('Done, successfully loading model') ############################################## if args.log_path == "checkpoint": log_folder = os.path.join(pwd_path, args.log_path, 'yolo') else: log_folder = args.log_path log_file = os.path.join(log_folder, 'log') list_model = os.listdir(log_folder) if os.path.exists(log_folder) else [] # in log folder have current model and want to resume training if "current_checkpoint.pth" in list_model and args.to_continue: checkpoint = torch.load(os.path.join( log_folder, "current_checkpoint.pth"), map_location=torch.device('cpu')) yolo.load_state_dict(checkpoint['state_dict']) optim_name = checkpoint["optimizer_name"] lr_rate = checkpoint['lr'] wd = checkpoint['wd'] momen = checkpoint['m'] start_epoch = checkpoint['epoch'] if optim_name == 'sgd': optimizer = optim.SGD(yolo.parameters(), lr=lr_rate, weight_decay=wd, momentum=momen ) print( f"Use optimizer SGD with lr {lr_rate} wdecay {wd} momentum {momen}") else: optimizer = optim.Adam(yolo.parameters(), lr=lr_rate, weight_decay=wd, ) print( f"Use optimizer Adam with lr {lr_rate} wdecay {wd}") optimizer.load_state_dict(checkpoint['optimizer']) if not args.use_cpu: for state in optimizer.state.values(): for k, v in state.items(): if isinstance(v, torch.Tensor): state[k] = v.cuda() sche_sd = checkpoint['sche'] if sche_sd and args.use_scheduler: lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR( optimizer, T_max=num_steps) lr_scheduler.load_state_dict(sche_sd) warmup_scheduler = GradualWarmupScheduler( optimizer, multiplier=1, total_epoch=4, after_scheduler=lr_scheduler) #if not args.use_cpu: # for state in lr_scheduler.state.values(): # for k, v in state.items(): # if isinstance(v, torch.Tensor): # state[k] = v.cuda() print(f"Resume Trainig at Epoch {checkpoint['epoch']} ") writer = create_writer(log_file) else: print("Loading new model") if args.use_pretrained: print("Loading pretrained weight") yolo.load_pretrained_by_num_class() if args.use_pretrained and args.freeze_backbone: grads_layer = ("81", "93", "105") for name, child in yolo.yolov3.named_children(): if not name in grads_layer: for each in child.parameters(): each.requires_grad = False print(f'Freezed all layers excludings {grads_layer}') if os.path.exists(log_file): old = datetime.now().strftime("%S%M%H_%d%m%Y") + "_old" shutil.copytree(log_file, os.path.join( log_folder, old), False, None) # copy to old folder shutil.rmtree(log_file, ignore_errors=True) # remove log lr_rate = args.lr wd = args.wd momen = args.momentum start_epoch = 1 if args.optim == 'sgd': print( f"Use optimizer SGD with lr {lr_rate} wdecay {wd} momentum {momen}") optimizer = optim.SGD( yolo.parameters(), lr=lr_rate, weight_decay=wd, momentum=momen) elif args.optim == 'adam': print(f"Use optimizer Adam with lr {lr_rate} wdecay {wd} ") optimizer = optim.Adam( yolo.parameters(), lr=lr_rate, weight_decay=wd) else: raise f"optimizer {args.optim} is not supported" writer = create_writer(log_file) #set up lr scheduler and warmup #num_steps = len(trainLoader) * args.epoch # move to line 174 if not lr_scheduler and args.use_scheduler: print('Set up scheduler and warmup') lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR( optimizer, T_max=num_steps) warmup_scheduler = GradualWarmupScheduler( optimizer, multiplier=1, total_epoch=4, after_scheduler=lr_scheduler) # Parallelism #if not args.use_cpu: #yolo = torch.nn.DataParallel(yolo) print('Start training model by GPU') if not args.use_cpu else print( 'Start training model by CPU') train_module( model=yolo, trainLoader=trainLoader, valLoader=valLoader, optimizer_name=args.optim, optimizer=optimizer, lr_scheduler=lr_scheduler, warmup_scheduler=warmup_scheduler, Epochs=args.epoch, use_cuda=not args.use_cpu, writer=writer, path=log_folder, lr_rate=lr_rate, wd=wd, momen=momen, start_epoch=start_epoch )
{"/Experiments/voc2012/data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Experiments/voc2012/model.py": ["/Yolov3/Model/yolov3.py"], "/Experiments/voc2012/visualize_data.py": ["/Yolov3/Dataset/dataformat.py"], "/Experiments/voc2012/voc_data.py": ["/Yolov3/Dataset/dataformat.py", "/Yolov3/Dataset/dataset.py"], "/Yolov3/Dataset/dataset.py": ["/Yolov3/Dataset/data_argument.py"], "/Yolov3/Model/yolov3.py": ["/Yolov3/Model/headv3.py"], "/Experiments/simple/debug_network.py": ["/Yolov3/Model/yolov3.py", "/Yolov3/Utils/train_module.py"], "/Experiments/simple/train.py": ["/Yolov3/Utils/train.py"], "/Yolov3/Utils/create_model.py": ["/Yolov3/Model/yolov3.py"], "/Yolov3/Utils/train.py": ["/Yolov3/Utils/train_module.py", "/Yolov3/Utils/args_train.py", "/Yolov3/Dataset/dataset.py", "/Yolov3/Utils/create_model.py"]}
42,114,264
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0016_remove_planparticipant_isdutyseen.py
# Generated by Django 3.1.4 on 2021-01-05 17:53 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('planning', '0015_auto_20210105_1747'), ] operations = [ migrations.RemoveField( model_name='planparticipant', name='isDutySeen', ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,265
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0004_auto_20201117_0042.py
# Generated by Django 3.1.2 on 2020-11-17 00:42 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('participation', '0003_auto_20201117_0042'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('planning', '0003_plan_group_link'), ] operations = [ migrations.AlterField( model_name='plan', name='club', field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='participation.club', verbose_name='باشگاه'), ), migrations.AlterField( model_name='plan', name='description', field=models.CharField(default='', max_length=256, verbose_name='توضیحات'), ), migrations.AlterField( model_name='plan', name='destination_address', field=models.CharField(default='', max_length=256, verbose_name='ادرس مقصد'), ), migrations.AlterField( model_name='plan', name='group_link', field=models.URLField(default='', verbose_name='لینک گروه'), ), migrations.AlterField( model_name='plan', name='head_man', field=models.CharField(default='', max_length=256, verbose_name='سرپرست'), ), migrations.AlterField( model_name='plan', name='start_datetime', field=models.DateTimeField(verbose_name='زمان و تاریخ شروع'), ), migrations.AlterField( model_name='plan', name='title', field=models.CharField(default='', max_length=50, verbose_name='عنوان'), ), migrations.AlterField( model_name='planparticipant', name='plan', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='planning.plan', verbose_name='برنامه'), ), migrations.AlterField( model_name='planparticipant', name='status', field=models.CharField(choices=[('PENDING', 'Pending'), ('ACCEPTED', 'Accepted'), ('REJECTED', 'Rejected')], max_length=255, verbose_name='وضعیت'), ), migrations.AlterField( model_name='planparticipant', name='user', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='کاربر'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,266
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/views.py
from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.http import HttpResponseRedirect from django.http.response import HttpResponseForbidden, HttpResponseBadRequest from django.shortcuts import render, get_object_or_404 from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext as _ from accounts.models import UserProfile from participation.models import Club, ClubMember from .forms import PlanForm, ChargeForm, PlanPictureForm, ReportForm from .models import Plan, PlanParticipant, Charge, PlanNotification, PlanPicture def plans_list_view(request, club_id=0): clubs = [] if club_id > 0: clubs = Club.objects.filter(pk=club_id) elif club_id == 0: clubs = Club.objects.all() elif club_id == -1 and request.user.is_authenticated: memberships = ClubMember.objects.filter(user=request.user).filter(pending=False) clubs = map(lambda memb: memb.club, memberships) plans = [] for club in clubs: plans += list(club.plan_set.all()) my_plans = None if request.user.is_authenticated: my_plans = PlanParticipant.objects.filter(user=request.user, status=str(PlanParticipant.MemberStatus.ACCEPTED)) my_plans = map(lambda memb: memb.plan, my_plans) my_plans = filter(lambda plan: plan in plans, my_plans) my_plans = list(my_plans) my_plans.sort(key=lambda plan: plan.start_datetime) my_plans.reverse() return render(request, 'planning/plans_list.html', { 'plans': plans, 'my_plans': my_plans, }) def plan_profile_view(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) plan_participant = None user = get_object_or_404(User, username=plan.head_man) headman = get_object_or_404(UserProfile, user=user) charges = Charge.objects.filter(plan= plan_id) totalCharge = 0 for c in charges: totalCharge += c.amount if request.user.is_authenticated and PlanParticipant.objects.filter(user=request.user, plan=plan).count(): plan_participant = PlanParticipant.objects.get(user=request.user, plan=plan) return render(request, 'planning/plan_profile.html', {'plan': plan, 'headman': headman, 'plan_participant': plan_participant, 'totalCharge': totalCharge}) @login_required def edit_plan_view(request, plan_id): # TODO permissions and roles not implemented plan = get_object_or_404(Plan, pk=plan_id) plan_head_man_list = User.objects.filter(username=plan.head_man) if plan.club.owner != request.user and (len(plan_head_man_list) == 0 or plan_head_man_list.first() != request.user): return HttpResponseForbidden() form = PlanForm(request.POST or None, instance=plan) if request.method == 'POST': if form.is_valid(): """ creating plan """ """ adding head man to plan participant """ plan = form.save(commit=False) if User.objects.filter(username=plan.head_man).count() != 0 and ClubMember.objects.filter( user=plan.head_man_user, pending=False, club=plan.club).count() != 0: plan.save() if PlanParticipant.objects.filter(user=plan.head_man_user, plan=plan).count() == 0: parti = PlanParticipant() parti.user = plan.head_man_user parti.plan = plan parti.status = PlanParticipant.MemberStatus.ACCEPTED parti.save() return HttpResponseRedirect(reverse('planning:plan_view', args=[plan.id])) else: form.add_error('head_man', _("Invalid head man username")) return render(request, 'planning/plan_edit.html', { 'form': form, 'plan': plan, }) return render(request, 'planning/plan_edit.html', {'form': form, 'plan': plan}) @login_required def addCharge(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) if PlanParticipant.objects.filter(plan=plan, user=request.user).count(): if request.method == 'POST': form = ChargeForm(data=request.POST) if form.is_valid(): charge = form.save(commit=False) charge.plan = plan charge.user = request.user charge.save() return HttpResponseRedirect(reverse('planning:plan_view', args=[plan.id])) else: charge_form = ChargeForm() return render(request, 'planning/add_charge.html', {'plan': plan, 'charge_form': charge_form}) return HttpResponseForbidden() @login_required def detail_plan_view(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) edit_access = False if plan.head_man_user == request.user or plan.club.owner == request.user: edit_access = True if request.method == 'POST': form = ReportForm(request.POST) if form.is_valid(): plan.report = form.cleaned_data['report'] plan.save() form = ReportForm({'report': plan.report}) return render(request, 'planning/plan_details.html', {'form': form, 'plan': plan, 'edit_access': edit_access}) @login_required def create_plan_view(request, club_id): # TODO permissions and roles not implemented club = get_object_or_404(Club, pk=club_id) if request.user != club.owner: return HttpResponseForbidden() form = PlanForm(request.POST or None) if request.method == 'POST': if form.is_valid(): """ creating plan """ """ adding head man to plan participant """ plan = form.save(commit=False) parti = PlanParticipant() if User.objects.filter(username=plan.head_man).count() != 0 and ClubMember.objects.filter( user=plan.head_man_user, pending=False, club=club).count() != 0: parti.user = plan.head_man_user plan.club = club parti.plan = plan parti.status = PlanParticipant.MemberStatus.ACCEPTED parti.role = "head man" plan.save() parti.save() return HttpResponseRedirect(reverse('planning:plan_view', args=[plan.id])) else: form.add_error('head_man', _("Invalid head man username")) return render(request, 'planning/plan_create.html', { 'form': form, 'club_id': club_id, }) return render(request, 'planning/plan_create.html', { 'form': form, 'club_id': club_id, }) @login_required def plan_participant_preregister(request, plan_id): # TODO permissions and roles not implemented - Check for user club registration plan = get_object_or_404(Plan, pk=plan_id) if PlanParticipant.objects.filter(user=request.user).filter(plan=plan).count(): return HttpResponseBadRequest("you are already a part of this plan!") PlanParticipant.objects.create(user=request.user, status=str(PlanParticipant.MemberStatus.PENDING), plan=plan) text = '{user} wants to join to your club'.format(user=request.user) PlanNotification(user=plan.club.owner, plan=plan, title='plan join request', description=text, time=timezone.now()).save() PlanNotification(user=plan.head_man_user, plan=plan, title='plan join request', description=text, time=timezone.now()).save() return HttpResponseRedirect(reverse('planning:plan_view', args=[plan.id])) @login_required def plan_members_and_requests_view(request, plan_id): ## TODO for requests plan = get_object_or_404(Plan, id=plan_id) members = PlanParticipant.objects.filter(plan=plan, status=str(PlanParticipant.MemberStatus.ACCEPTED)) pending = PlanParticipant.objects.filter(plan=plan, status=str(PlanParticipant.MemberStatus.PENDING)) charges = Charge.objects.filter(plan=plan_id) totalPlanCarges = 0 for p in charges: totalPlanCarges += p.amount totalPlanCarges /= members.count() if not ClubMember.objects.filter(club=plan.club, user=request.user).count(): return HttpResponseForbidden() edit_access = False if plan.head_man_user == request.user or plan.club.owner == request.user: edit_access = True return render(request, 'planning/plan_members_and_requests.html', { 'members': members, 'pending': pending if edit_access else [], 'plan': plan, 'edit_access': edit_access, 'avgPay': totalPlanCarges }) @login_required def answer_request_view(request, req_id, accept): req = get_object_or_404(PlanParticipant, pk=req_id) plan = req.plan if plan.head_man != str(request.user) and plan.club.owner != request.user: return HttpResponseForbidden() if accept == 'ACCEPT': req.status = PlanParticipant.MemberStatus.ACCEPTED elif accept == 'REJECT': req.status = PlanParticipant.MemberStatus.REJECTED req.save() return HttpResponseRedirect(reverse('planning:plan_join_members_and_requests', args=(plan.id,))) @login_required def addDuty(request, plan_id, req_id): pp = get_object_or_404(PlanParticipant, pk=req_id) pp.duty = request.POST.get('duty') pp.save() PlanNotification(user=pp.user, plan=get_object_or_404(Plan, id=plan_id), title='new Duty', description=pp.duty, time=timezone.now()).save() return HttpResponseRedirect(reverse('planning:plan_join_members_and_requests', args=(plan_id,))) @login_required def Charges(request, plan_id): charges = Charge.objects.filter(plan=plan_id) plan = get_object_or_404(Plan, id=plan_id) totalPlanCarges = 0 for p in charges: totalPlanCarges += p.amount return render(request, 'planning/plan_charges.html', {'charges': charges, 'plan': plan, 'total': totalPlanCarges}) @login_required def addRole(request, plan_id, req_id): pp = get_object_or_404(PlanParticipant, pk=req_id) pp.role = request.POST.get('role') pp.save() PlanNotification(user=pp.user, plan=get_object_or_404(Plan, id=plan_id), title='new role assigned', description=pp.role, time=timezone.now()).save() return HttpResponseRedirect(reverse('planning:plan_join_members_and_requests', args=(plan_id,))) @login_required def recordCriticism(request, plan_id, user_id): user = get_object_or_404(User, id=user_id) plan = get_object_or_404(Plan, id=plan_id) if request.method == 'POST': criticism = request.POST.get('criticism') PlanNotification(user=user, plan=plan, title='new criticism', description=criticism, time=timezone.now()).save() return HttpResponseRedirect(reverse('planning:plan_join_members_and_requests', args=(plan_id,))) else: return render(request, 'planning/record_criticism.html', {'user': user, 'plan': plan}) @login_required def addPicture(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) if PlanParticipant.objects.filter(plan=plan, user=request.user).count(): if request.method == 'POST': picture_form = PlanPictureForm(request.POST, request.FILES) if picture_form.is_valid(): picture = picture_form.save(commit=False) picture.plan = plan picture.user = request.user picture.save() return HttpResponseRedirect(reverse('planning:plan_view', args=[plan.id])) else: picture_form = PlanPictureForm() return render(request, 'planning/add_picture.html', {'plan': plan, 'form': picture_form}) return HttpResponseForbidden() @login_required def showPictures(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) pictures = PlanPicture.objects.filter(plan=plan, isPublic=True) return render(request, 'planning/plan_pictures.html', {'pictures': pictures, 'plan': plan}) @login_required def managePictures(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) if plan.head_man_user == request.user: pictures = PlanPicture.objects.filter(plan=plan) return render(request, 'planning/manage_pictures.html', {'pictures': pictures, 'plan': plan}) else: return HttpResponseForbidden() @login_required def publicPicture(request, plan_id, pic_id): plan = get_object_or_404(Plan, pk=plan_id) if plan.head_man_user == request.user: picture = PlanPicture.objects.get(id=pic_id) picture.isPublic = bool(request.POST.get('public')) picture.save() return HttpResponseRedirect(reverse('planning:managePictures', args=(plan_id,))) else: return HttpResponseForbidden() @login_required def reportSpam(request, plan_id): plan = get_object_or_404(Plan, pk=plan_id) if request.method == 'POST': text = request.POST.get('spam') PlanNotification(user=plan.head_man_user, plan=plan, title='picture report', description=text, time=timezone.now()).save() PlanNotification(user=plan.club.owner, plan=plan, title='picture report', description=text, time=timezone.now()).save() return HttpResponseRedirect(reverse('planning:pictures', args=(plan_id,))) else: return render(request, 'planning/report_spam.html', {'plan': plan})
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,267
amirhkarimi1999/koohnavard
refs/heads/master
/src/accounts/forms.py
from django import forms from django.contrib.auth.models import User from accounts.models import UserProfile class UserRegisterForm(forms.ModelForm): class Meta: model = User fields = ['username', 'password', 'password'] widgets = { 'password': forms.PasswordInput(), } class UserLoginForm(forms.ModelForm): class Meta: model = User fields = ['username', 'password'] class UserProfileInfoForm(forms.ModelForm): class Meta: model = UserProfile fields = ['first_name', 'last_name', 'email', 'bio', 'profile_pic']
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,268
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/admin.py
from django.contrib import admin # Register your models here. from planning.models import Plan, PlanParticipant, PlanNotification, PlanPicture admin.site.register(Plan) admin.site.register(PlanParticipant) admin.site.register(PlanNotification) admin.site.register(PlanPicture)
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,269
amirhkarimi1999/koohnavard
refs/heads/master
/src/accounts/tests.py
from django.test import TestCase from django.contrib.auth.models import User from accounts.models import UserProfile class ProfileTest(TestCase): def setUp(self): self.prof = UserProfile() self.prof.user = User(username='testuser') self.prof.user.save() self.prof.first_name = "test_first_name" self.prof.last_name = "test_last_name" self.prof.email = "test@gmail.com" self.prof.bio = "test_bio" self.prof.save() def test_profile(self): prof = UserProfile() prof.user = User(username='myuser') prof.user.save() prof.first_name = "my_first_name" prof.last_name = "my_last_name" prof.email = "my@gmail.com" prof.bio = "my_bio" prof.save() record = UserProfile.objects.get(pk=2) self.assertEqual(prof, record) def test_profile_to_string(self): self.assertEqual(self.prof.__str__(), "test_first_name test_last_name")
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,270
amirhkarimi1999/koohnavard
refs/heads/master
/src/home/views.py
from django.contrib.auth.models import User from django.shortcuts import render from participation.models import Club from planning.models import Plan def home_page(request): """View function for home page of site.""" user_cnt = User.objects.filter().count() club_cnt = Club.objects.filter().count() plan_cnt = Plan.objects.filter().count() context = { 'user_cnt': user_cnt, 'club_cnt': club_cnt, 'plan_cnt': plan_cnt } # Render the HTML template home.html with the data in the context variable return render(request, 'home/home.html', context=context)
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,271
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0020_plan_report.py
# Generated by Django 3.1.2 on 2021-02-19 10:18 import markdownx.models from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('planning', '0019_auto_20210219_0828'), ] operations = [ migrations.AddField( model_name='plan', name='report', field=markdownx.models.MarkdownxField(default=''), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,272
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0019_auto_20210219_0828.py
# Generated by Django 3.1.2 on 2021-02-19 08:28 import datetime from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0018_remove_plan_report'), ] operations = [ migrations.AlterField( model_name='plan', name='start_datetime', field=models.DateTimeField(default=datetime.date.today, verbose_name='start_datetime'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,273
amirhkarimi1999/koohnavard
refs/heads/master
/src/participation/urls.py
from django.urls import path from . import views app_name = 'participation' urlpatterns = [ path('', views.clubs_list_view, name='clubs_list'), path('<int:club_id>/', views.club_profile_view, name='club_view'), path('<int:club_id>/edit/', views.edit_club_view, name='club_edit'), path('<int:club_id>/requests/', views.club_requests_view, name='club_join_requests'), path('new/', views.create_club_view, name='club_create'), path('<int:club_id>/join/', views.join_request_view, name='club_join'), path('<int:club_id>/leave/', views.leave_request_view, name='club_leave'), path('admin/reqs/answer/<int:req_id>/<int:accept>/', views.answer_request_view, name='answer_club_join_request'), path('admin/members/kick/<int:req_id>/', views.kick_club_member_view, name='kick_club_member'), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,274
amirhkarimi1999/koohnavard
refs/heads/master
/src/participation/migrations/0003_auto_20201117_0042.py
# Generated by Django 3.1.2 on 2020-11-17 00:42 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('participation', '0002_clubmember'), ] operations = [ migrations.AlterField( model_name='club', name='owner', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='مدیر'), ), migrations.AlterField( model_name='club', name='title', field=models.CharField(max_length=200, unique=True, verbose_name='عنوان'), ), migrations.AlterField( model_name='clubmember', name='club', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='participation.club', verbose_name='باشگاه'), ), migrations.AlterField( model_name='clubmember', name='pending', field=models.BooleanField(default=True, verbose_name='در حال انتظار'), ), migrations.AlterField( model_name='clubmember', name='user', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='کاربر'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,275
amirhkarimi1999/koohnavard
refs/heads/master
/src/accounts/views.py
from django.contrib.auth import authenticate, login, logout from django.http.response import HttpResponseRedirect, HttpResponse from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.urls import reverse, reverse_lazy from django.views import generic from planning.models import PlanParticipant, PlanNotification from accounts.forms import UserRegisterForm, UserProfileInfoForm from accounts.models import UserProfile def index(request): return HttpResponseRedirect(reverse('participation:clubs_list')) def register(request): # TODO permissions and roles not implemented """ redirecting to home if authenticated """ if request.user.is_authenticated: return HttpResponseRedirect(reverse('participation:clubs_list')) """ registering """ if request.method == 'POST': user_form = UserRegisterForm(data=request.POST) profile_form = UserProfileInfoForm(data=request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user if 'profile_pic' in request.FILES: print('found it') profile.profile_pic = request.FILES['profile_pic'] profile.save() login(request, user) return HttpResponseRedirect(reverse('participation:clubs_list')) else: print(user_form.errors, profile_form.errors) else: user_form = UserRegisterForm() profile_form = UserProfileInfoForm() return render(request, 'accounts/registration.html', {'user_form': user_form, 'profile_form': profile_form}) def login_user(request): """ redirecting to home if authenticated """ if request.user.is_authenticated: return HttpResponseRedirect(reverse('participation:clubs_list')) """ logging in """ if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(username=username, password=password) if user: if user.is_active: login(request, user) return HttpResponseRedirect(reverse('accounts:index')) else: return HttpResponse("Your account was inactive.") else: print("Someone tried to login and failed.") print("They used username: {} and password: {}".format(username, password)) return HttpResponse("Invalid login details given") else: return render(request, 'accounts/login.html', {}) @login_required def logout_user(request): logout(request) return HttpResponseRedirect(reverse('participation:clubs_list')) @login_required def duties(request): planParticipants = PlanParticipant.objects.filter(user=request.user, status=str(PlanParticipant.MemberStatus.ACCEPTED), duty__isnull=False) return render(request, 'accounts/duties.html', {'planParticipants': planParticipants}) @login_required def profile_view(request): if not request.user.is_authenticated: return HttpResponseRedirect(reverse('accounts:register')) profile_form = UserProfileInfoForm(data=request.POST or None) if request.method == 'POST': if profile_form.is_valid(): profile = profile_form.save(commit=False) user = get_object_or_404(UserProfile, user=request.user) if 'profile_pic' in request.FILES: print('found profile pic') user.profile_pic = request.FILES['profile_pic'] if profile.first_name : user.first_name = profile.first_name if profile.last_name : user.last_name = profile.last_name if profile.email : user.email = profile.email if profile.bio: user.bio = profile.bio user.save() return HttpResponseRedirect(reverse('accounts:seeProfile')) else: print(profile_form.errors) return render(request, 'accounts/profile.html', {'profile_form': profile_form}) @login_required def see_profile(request): if not request.user.is_authenticated: return HttpResponseRedirect(reverse('accounts:register')) else: user = get_object_or_404(UserProfile, user=request.user) return render(request, 'accounts/see_profile.html', {'userProfile': user}) # class UserEditView(generic.UpdateView): # form_class = UserProfileInfoForm # template_name = 'accounts/profile.html' # success_url = reverse_lazy('participation:clubs_list') # # def get_object(self, queryset=None): # return self.request.user @login_required def seeInbox(request): notifications = PlanNotification.objects.filter(user=request.user).order_by('-time') for notif in notifications: notif.isSeen = max(0, notif.isSeen - 1) notif.save() return render(request, 'accounts/inbox.html', {'notifications': notifications})
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,276
amirhkarimi1999/koohnavard
refs/heads/master
/src/participation/models.py
from django.contrib.auth.models import User from django.db import models from django.utils.translation import gettext as _ from planning.models import Plan class Club(models.Model): title = models.CharField(max_length=200, blank=False, null=False, unique=True, verbose_name=_('title')) owner = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('owner')) def __str__(self): return self.title @property def members_cnt(self): return ClubMember.objects.filter(club=self).filter(pending=False).count() @property def plans_cnt(self): return Plan.objects.filter(club=self).count() class ClubMember(models.Model): club = models.ForeignKey(Club, on_delete=models.CASCADE, verbose_name=_('club')) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('user')) pending = models.BooleanField(default=True, verbose_name=_('pending'))
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,277
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0002_plan_head_man.py
# Generated by Django 3.0.4 on 2020-11-14 02:04 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0001_initial'), ] operations = [ migrations.AddField( model_name='plan', name='head_man', field=models.CharField(default='', max_length=256), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,278
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0007_planparticipant_isdutyseen.py
# Generated by Django 3.1.3 on 2020-12-25 10:32 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0006_planparticipant_duty'), ] operations = [ migrations.AddField( model_name='planparticipant', name='isDutySeen', field=models.BooleanField(default=False, verbose_name='isDutyseen'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,279
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0006_planparticipant_duty.py
# Generated by Django 3.1.3 on 2020-12-23 12:05 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0005_auto_20201208_1040'), ] operations = [ migrations.AddField( model_name='planparticipant', name='duty', field=models.CharField(max_length=1000, null=True, verbose_name='duty'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,280
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0017_planpicture.py
# Generated by Django 3.1.4 on 2021-01-06 05:42 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('planning', '0016_remove_planparticipant_isdutyseen'), ] operations = [ migrations.CreateModel( name='PlanPicture', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(default='', max_length=50, verbose_name='title')), ('caption', models.CharField(default='', max_length=256, verbose_name='caption')), ('image', models.ImageField(upload_to='plan_pictures', verbose_name='image')), ('isPublic', models.BooleanField(default=False, verbose_name='isPublic')), ('plan', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='planning.plan', verbose_name='club')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='کاربر')), ], ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,281
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0015_auto_20210105_1747.py
# Generated by Django 3.1.4 on 2021-01-05 17:47 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0014_plannotification'), ] operations = [ migrations.AlterField( model_name='plannotification', name='isSeen', field=models.IntegerField(default=2, verbose_name='isSeen'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,282
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0005_auto_20201208_1040.py
# Generated by Django 3.1.4 on 2020-12-08 10:40 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('participation', '0004_auto_20201208_1040'), ('planning', '0004_auto_20201117_0042'), ] operations = [ migrations.AlterField( model_name='plan', name='club', field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='participation.club', verbose_name='club'), ), migrations.AlterField( model_name='plan', name='description', field=models.CharField(default='', max_length=256, verbose_name='description'), ), migrations.AlterField( model_name='plan', name='destination_address', field=models.CharField(default='', max_length=256, verbose_name='destination_address'), ), migrations.AlterField( model_name='plan', name='group_link', field=models.URLField(default='', verbose_name='group_link'), ), migrations.AlterField( model_name='plan', name='head_man', field=models.CharField(default='', max_length=256, verbose_name='head_man'), ), migrations.AlterField( model_name='plan', name='start_datetime', field=models.DateTimeField(verbose_name='start_datetime'), ), migrations.AlterField( model_name='plan', name='title', field=models.CharField(default='', max_length=50, verbose_name='title'), ), migrations.AlterField( model_name='planparticipant', name='plan', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='planning.plan', verbose_name='plan'), ), migrations.AlterField( model_name='planparticipant', name='status', field=models.CharField(choices=[('PENDING', 'Pending'), ('ACCEPTED', 'Accepted'), ('REJECTED', 'Rejected')], max_length=255, verbose_name='status'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,283
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0010_auto_20201226_1940.py
# Generated by Django 3.1.3 on 2020-12-26 19:40 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('planning', '0009_charge'), ] operations = [ migrations.AlterField( model_name='charge', name='plan', field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='planning.plan', verbose_name='club'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,284
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/forms.py
from django import forms from .models import Plan, Charge, PlanPicture class PlanForm(forms.ModelForm): class Meta: model = Plan fields = ['title', 'description', 'destination_address', 'start_datetime', 'head_man', 'group_link'] class ChargeForm(forms.ModelForm): class Meta: model = Charge fields = ['title', 'description', 'amount'] class ReportForm(forms.ModelForm): class Meta: model = Plan fields = ['report'] class PlanPictureForm(forms.ModelForm): class Meta: model = PlanPicture fields = ['title', 'image', 'caption']
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,285
amirhkarimi1999/koohnavard
refs/heads/master
/src/participation/migrations/0004_auto_20201208_1040.py
# Generated by Django 3.1.4 on 2020-12-08 10:40 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('participation', '0003_auto_20201117_0042'), ] operations = [ migrations.AlterField( model_name='club', name='owner', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='owner'), ), migrations.AlterField( model_name='club', name='title', field=models.CharField(max_length=200, unique=True, verbose_name='title'), ), migrations.AlterField( model_name='clubmember', name='club', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='participation.club', verbose_name='club'), ), migrations.AlterField( model_name='clubmember', name='pending', field=models.BooleanField(default=True, verbose_name='pending'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,286
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/templatetags/custom_tags.py
from django import template register = template.Library() from ..models import PlanNotification @register.simple_tag(name='unseen_notifs') def unseen_notifications_count(user): return PlanNotification.objects.filter(isSeen=2, user=user).count()
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,287
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0011_auto_20201226_1942.py
# Generated by Django 3.1.3 on 2020-12-26 19:42 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0010_auto_20201226_1940'), ] operations = [ migrations.AlterField( model_name='charge', name='amount', field=models.DecimalField(decimal_places=0, max_digits=20, verbose_name='amount'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,288
amirhkarimi1999/koohnavard
refs/heads/master
/src/accounts/models.py
from django.contrib.auth.models import User from django.db import models from django.utils.translation import gettext as _ # Create your models here. class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) first_name = models.CharField(max_length=30, blank=True, null=True, verbose_name=_('first name')) last_name = models.CharField(max_length=30, blank=True, null=True, verbose_name=_('last name')) email = models.EmailField(max_length=254, blank=True, null=True, verbose_name=_('email')) bio = models.CharField(max_length=400, blank=True, null=True, verbose_name=_('bio')) profile_pic = models.ImageField(upload_to='profile_pics', blank=True, verbose_name=_("profile_pic")) def __str__(self): return str(self.first_name) + " " + str(self.last_name)
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,289
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/urls.py
from django.urls import path from . import views app_name = 'planning' urlpatterns = [ path('', views.plans_list_view, name='all_plans_list'), path('club/<int:club_id>', views.plans_list_view, name='plans_list'), path('<int:plan_id>/', views.plan_profile_view, name='plan_view'), path('edit/<int:plan_id>', views.edit_plan_view, name='plan_edit'), path('<int:club_id>/new/', views.create_plan_view, name='plan_create'), path('details/<int:plan_id>', views.detail_plan_view, name='plan_details'), path('preregister/<int:plan_id>/', views.plan_participant_preregister, name='plan_participant_preregister'), path('<int:plan_id>/members/', views.plan_members_and_requests_view, name='plan_join_members_and_requests'), path('<int:plan_id>/charges/', views.Charges, name='charges'), path('<int:plan_id>/addcharge/', views.addCharge, name='addCharge'), path('<int:plan_id>/addpicture/', views.addPicture, name='addPicture'), path('<int:plan_id>/pictures/', views.showPictures, name='pictures'), path('<int:plan_id>/reportspam/', views.reportSpam, name='reportSpam'), path('<int:plan_id>/managepictures/', views.managePictures, name='managePictures'), path('<int:plan_id>/pulicpicture/<int:pic_id>/', views.publicPicture, name='publicPicture'), path('admin/reqs/answer/<int:req_id>/<str:accept>/', views.answer_request_view, name='answer_plan_join_request'), path('<int:plan_id>/addduty/<int:req_id>/', views.addDuty, name='addDuty'), path('<int:plan_id>/addrole/<int:req_id>/', views.addRole, name='addRole'), path('<int:plan_id>/addcriticism/<int:user_id>/', views.recordCriticism, name='addCriticism'), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,290
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0003_plan_group_link.py
# Generated by Django 3.0.4 on 2020-11-14 02:06 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0002_plan_head_man'), ] operations = [ migrations.AddField( model_name='plan', name='group_link', field=models.URLField(default=''), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,291
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/tests.py
from django.test import TestCase from django.contrib.auth.models import User from planning.models import Plan, Charge, PlanParticipant from participation.models import Club, ClubMember from accounts.models import UserProfile class PlanTest(TestCase): def setUp(self): # info self.title = 'Sangchal to Diva' self.description = 'Lets go nuts' self.destination_address = 'Diva' self.head_man_name = 'aryan molanayi' # create a club self.club = Club.objects.create(title='my club', owner=User.objects.create(username='club_owner')) # create a head_man user head_man_user = User.objects.create(username=self.head_man_name) head_man_prof = UserProfile.objects.create(user=head_man_user) head_man_user.save() head_man_prof.save() self.head_user=head_man_user self.head_prof=head_man_prof self.head_club_member = ClubMember.objects.create(club=self.club, user=head_man_user, pending=False) self.plan = Plan.objects.create(club=self.club, title=self.title, description=self.description, destination_address=self.destination_address, head_man=self.head_man_name) # register the headman to the plan self.head_participant = PlanParticipant.objects.create(plan=self.plan, user=head_man_user, status='ACCEPTED') ## create some dummy users to be able to use below self.user1 = User.objects.create(username="user1") self.user2 = User.objects.create(username='user2') self.user1.save() self.user2.save() def test_plan_str(self): self.assertEqual(self.plan.__str__(), self.title + " " + self.club.__str__()) def test_head_man_user_property(self): self.assertEqual(User.objects.get(username=self.head_man_name), self.plan.head_man_user) def test_participant_count(self): self.assertEqual(self.plan.participants_cnt, 1) def test_add_participant(self): self.assertEqual(self.plan.participants_cnt, 1) participant1 = PlanParticipant.objects.create(plan=self.plan, user=self.user1, status='ACCEPTED') participant1.save() self.assertEqual(self.plan.participants_cnt, 2) participant2 = PlanParticipant.objects.create(plan=self.plan, user=self.user2, status='PENDING') participant2.save() self.assertEqual(self.plan.participants_cnt, 2) def test_delete_participant(self): self.assertEqual(self.plan.participants_cnt, 1) participant1 = PlanParticipant.objects.create(plan=self.plan, user=self.user1, status='ACCEPTED') participant1.save() self.assertEqual(self.plan.participants_cnt, 2) participant2 = PlanParticipant.objects.create(plan=self.plan, user=self.user2, status='PENDING') participant2.save() self.assertEqual(self.plan.participants_cnt, 2) participant1.delete() self.assertEqual(self.plan.participants_cnt, 1) participant2.delete() self.assertEqual(self.plan.participants_cnt, 1) def test_total_pay(self): Charge.objects.create(plan=self.plan, user=self.plan.head_man_user, title='ash reshte', description='eat', amount=20) self.assertEqual(self.head_participant.user_total_pay, 20) Charge.objects.create(plan=self.plan, user=self.plan.head_man_user, title='lubya polo', description='eat', amount=50) self.assertEqual(self.head_participant.user_total_pay, 70) Charge.objects.create(plan=self.plan, user=self.plan.head_man_user, title='bread', description='buy', amount=-10) self.assertEqual(self.head_participant.user_total_pay, 60) # someone who is not a member of the club shouldn't be able to particiapte in the plan def test_participation_of_a_non_club_member(self): participant1 = PlanParticipant.objects.create(plan=self.plan, user=self.user1) participant1.save() self.assertEqual(self.plan.participants_cnt, 1) def test_get_user_function_plan_participant(self): self.assertEqual(self.head_prof, self.head_participant.getUser) """ todo! getting integrity error for the following two functions. """ # def test_charges_after_deleting_plan(self): # Charge.objects.create(plan=self.plan, user=self.plan.head_man_user, title='ash reshte', # description='eat', amount=20) # self.assertEqual(self.head_participant.user_total_pay, 20) # self.plan.delete() # self.assertEqual(self.head_participant.user_total_pay, 0) # # # # a plan lives even after deleting its club # def test_plan_after_deleting_club(self): # self.plan.club.delete() # try: # Plan.objects.get(headman=self.head_man_name) # except Plan.DoesNotExist: # self.assertTrue(False) # else: # self.assertTrue(True)
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,292
amirhkarimi1999/koohnavard
refs/heads/master
/src/participation/views.py
from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.urls import reverse from django.http import HttpResponseRedirect, HttpResponseForbidden, HttpResponseBadRequest from django.utils import timezone from accounts.models import UserProfile from planning.models import PlanParticipant, PlanNotification from .models import Club, ClubMember from .forms import ClubForm def clubs_list_view(request): if request.user.is_authenticated: my_reqs = ClubMember.objects.filter(user=request.user, pending=False) my_clubs = list(map(lambda req: req.club, my_reqs)) pending_reqs = ClubMember.objects.filter(user=request.user, pending=True) pending_clubs = list(map(lambda req: req.club, pending_reqs)) other_clubs = list(filter(lambda club: club not in my_clubs and club not in pending_clubs, Club.objects.all())) return render(request, 'participation/clubs_list.html', { 'auth': True, 'my_clubs': my_clubs, 'pending_clubs': pending_clubs, 'other_clubs': other_clubs, }) else: return render(request, 'participation/clubs_list.html', { 'auth': False, 'clubs': Club.objects.all(), }) def club_profile_view(request, club_id): club = get_object_or_404(Club, pk=club_id) members = club.clubmember_set.filter(pending=False) owner = get_object_or_404(UserProfile, user=club.owner) req = ClubMember.objects.filter(user=request.user, club=club).first() return render(request, 'participation/club_profile.html', { 'club': club, 'owner': owner, 'members': members, 'is_mine': club.owner == request.user, 'is_member': req is not None and not req.pending, 'is_pending': req is not None and req.pending, }) @login_required def edit_club_view(request, club_id): club = get_object_or_404(Club, pk=club_id) if club.owner != request.user: return HttpResponseForbidden() form = ClubForm(request.POST or None, instance=club) if request.method == 'POST': if form.is_valid(): club = form.save() return HttpResponseRedirect(reverse('participation:club_view', args=(club.id,))) return render(request, 'participation/club_edit.html', { 'form': form, 'club': club, }) @login_required def club_requests_view(request, club_id): club = get_object_or_404(Club, pk=club_id) is_owner = club.owner == request.user reqs = ClubMember.objects.filter(club=club, pending=True) temp = [] for m in reqs: temp.append(get_object_or_404(UserProfile, user=m.user)) reqs = temp members = ClubMember.objects.filter(club=club, pending=False) temp = [] for m in members: temp.append(get_object_or_404(UserProfile, user=m.user)) members = temp return render(request, 'participation/club_requests.html', { 'reqs': reqs if is_owner else [], 'members': members, 'club': club, 'is_owner': is_owner, }) @login_required def create_club_view(request): form = ClubForm(request.POST or None) if request.method == 'POST': if form.is_valid(): club = form.save(commit=False) club.owner = request.user club.save() ClubMember.objects.create(user=club.owner, club=club, pending=False) return HttpResponseRedirect(reverse('participation:club_view', args=(club.id,))) return render(request, 'participation/club_create.html', {'form': form}) @login_required def join_request_view(request, club_id): club = get_object_or_404(Club, pk=club_id) member = ClubMember.objects.filter(club=club, user=request.user) if member.count() != 0 or member.first() == club.owner: return HttpResponseBadRequest() ClubMember.objects.create(user=request.user, club=club) return HttpResponseRedirect(reverse('participation:clubs_list')) @login_required def leave_request_view(request, club_id): club = get_object_or_404(Club, pk=club_id) member = ClubMember.objects.filter(club=club, user=request.user) if member.count() == 0 or member.first() == club.owner: return HttpResponseBadRequest() member.delete() return HttpResponseRedirect(reverse('participation:clubs_list')) @login_required def answer_request_view(request, req_id, accept): req = get_object_or_404(ClubMember, pk=req_id) club = req.club if club.owner != request.user: return HttpResponseForbidden() if accept: req.pending = False req.save() elif req.user != club.owner: req.delete() return HttpResponseRedirect(reverse('participation:club_join_requests', args=(club.id,))) @login_required def kick_club_member_view(request, req_id): return answer_request_view(request, req_id, 0)
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,293
amirhkarimi1999/koohnavard
refs/heads/master
/src/participation/tests.py
from django.test import TestCase from participation.models import Club, ClubMember from accounts.models import User def create_club(): user = User.objects.create(username='my_username') return Club.objects.create(title='my club', owner=user) # Create your tests here. class ClubModelTests(TestCase): def test_club_creation(self): club = create_club() owner = ClubMember.objects.create(user=club.owner, club=club, pending=False) self.assertEqual(club.members_cnt, 1) self.assertEqual(owner.pending, False) def test_add_member_to_club(self): club = create_club() user2 = User.objects.create(username='my_username2') owner = ClubMember.objects.create(user=club.owner, club=club, pending=False) club_member = ClubMember.objects.create(user=user2, club=club) self.assertEqual(club_member.pending, True) self.assertEqual(club.members_cnt, 1) club_member.pending = False club_member.save() self.assertEqual(club.members_cnt, 2) def test_delete_member_from_club(self): user = User.objects.create(username='my_username') club = Club.objects.create(title='my club', owner=user) owner = ClubMember.objects.create(user=club.owner, club=club, pending=False) user2 = User.objects.create(username='my_username2') club_member = ClubMember.objects.create(user=user2, club=club, pending=False) user2.delete() self.assertEqual(club.members_cnt, 1) def test_delete_owner_from_club(self): user = User.objects.create(username='my_username') club = Club.objects.create(title='my club', owner=user) owner = ClubMember.objects.create(user=club.owner, club=club, pending=False) user.delete() try: club.refresh_from_db() except Club.DoesNotExist: self.assertTrue(True) else: self.assertTrue(False)
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,294
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0018_remove_plan_report.py
# Generated by Django 3.1.4 on 2021-01-07 09:15 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('planning', '0017_planpicture'), ] operations = [ migrations.RemoveField( model_name='plan', name='report', ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,295
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0001_initial.py
# Generated by Django 3.0.4 on 2020-11-13 23:00 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('participation', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Plan', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(default='', max_length=50)), ('description', models.CharField(default='', max_length=256)), ('destination_address', models.CharField(default='', max_length=256)), ('start_datetime', models.DateTimeField()), ('club', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='participation.Club')), ], ), migrations.CreateModel( name='PlanParticipant', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('status', models.CharField(choices=[('PENDING', 'Pending'), ('ACCEPTED', 'Accepted'), ('REJECTED', 'Rejected')], max_length=255)), ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='planning.Plan')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,296
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/models.py
import datetime from django.contrib.auth.models import User from django.db import models from django.utils.translation import gettext as _ from markdownx.models import MarkdownxField # Create your models here. from accounts.models import UserProfile class Plan(models.Model): club = models.ForeignKey('participation.Club', null=False, on_delete=models.DO_NOTHING, verbose_name=_('club')) title = models.CharField(max_length=50, null=False, default="", verbose_name=_('title')) description = models.CharField(max_length=256, null=False, default="", verbose_name=_('description')) destination_address = models.CharField(max_length=256, null=False, default="", verbose_name=_('destination_address')) start_datetime = models.DateTimeField(verbose_name=_('start_datetime'), default=datetime.date.today) head_man = models.CharField(max_length=256, null=False, default="", verbose_name=_('head_man')) group_link = models.URLField(default="", verbose_name=_('group_link')) report = MarkdownxField(default='') def __str__(self): return str(self.title) + " " + str(self.club) @property def head_man_user(self): return User.objects.get(username=self.head_man) @property def participants_cnt(self): return PlanParticipant.objects.filter(plan=self).filter( status=str(PlanParticipant.MemberStatus.ACCEPTED)).count() class Charge(models.Model): plan = models.ForeignKey('planning.Plan', null=False, on_delete=models.DO_NOTHING, verbose_name=_('club')) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('user')) title = models.CharField(max_length=50, null=False, default="", verbose_name=_('title')) description = models.CharField(max_length=256, null=False, default="", verbose_name=_('description')) amount = models.DecimalField(max_digits=20, decimal_places=0, null=False, verbose_name=_('amount')) class PlanParticipant(models.Model): class MemberStatus(models.TextChoices): PENDING = "PENDING", ACCEPTED = "ACCEPTED", REJECTED = "REJECTED", @classmethod def choices(cls): print(tuple((i.name, i.value) for i in cls)) return tuple((i.name, i.value) for i in cls) plan = models.ForeignKey(Plan, null=False, on_delete=models.CASCADE, verbose_name=_('plan')) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('user')) status = models.CharField(max_length=255, choices=MemberStatus.choices, verbose_name=_('status')) duty = models.CharField(max_length=1000, null=True, verbose_name=_('duty')) role = models.CharField(max_length=40, null=True, verbose_name=_('role')) @property def getUser(self): return UserProfile.objects.get(user=self.user) @property def user_total_pay(self): charges = Charge.objects.filter(plan=self.plan, user=self.user) totalPlanCarges = 0 for p in charges: totalPlanCarges += p.amount return totalPlanCarges class PlanNotification(models.Model): plan = models.ForeignKey(Plan, null=False, on_delete=models.CASCADE, verbose_name=_('plan')) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('user')) title = models.CharField(max_length=50, null=False, default="", verbose_name=_('title')) description = models.CharField(max_length=256, null=False, default="", verbose_name=_('description')) time = models.DateTimeField(verbose_name=_('time')) isSeen = models.IntegerField(default=2, verbose_name=_('isSeen')) class PlanPicture(models.Model): plan = models.ForeignKey('planning.Plan', null=False, on_delete=models.DO_NOTHING, verbose_name=_('club')) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('user')) title = models.CharField(max_length=50, null=False, default="", verbose_name=_('title')) caption = models.CharField(max_length=256, null=False, default="", verbose_name=_('caption')) image = models.ImageField(null=False, verbose_name=_('image'), upload_to='plan_pictures') isPublic = models.BooleanField(default=False, verbose_name=_('isPublic'))
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,297
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0013_auto_20210105_0951.py
# Generated by Django 3.1.4 on 2021-01-05 09:51 from django.db import migrations import markdownx.models class Migration(migrations.Migration): dependencies = [ ('planning', '0012_plan_report'), ] operations = [ migrations.AlterField( model_name='plan', name='report', field=markdownx.models.MarkdownxField(default=''), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,298
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0014_plannotification.py
# Generated by Django 3.1.4 on 2021-01-05 16:48 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('planning', '0013_auto_20210105_0951'), ] operations = [ migrations.CreateModel( name='PlanNotification', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(default='', max_length=50, verbose_name='title')), ('description', models.CharField(default='', max_length=256, verbose_name='description')), ('time', models.DateTimeField(verbose_name='time')), ('isSeen', models.BooleanField(default=False, verbose_name='isSeen')), ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='planning.plan', verbose_name='plan')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='کاربر')), ], ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,299
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0012_plan_report.py
# Generated by Django 3.1.3 on 2020-12-26 20:29 from django.db import migrations import markdownx.models class Migration(migrations.Migration): dependencies = [ ('planning', '0011_auto_20201226_1942'), ] operations = [ migrations.AddField( model_name='plan', name='report', field=markdownx.models.MarkdownxField(null=True), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,114,300
amirhkarimi1999/koohnavard
refs/heads/master
/src/planning/migrations/0008_planparticipant_role.py
# Generated by Django 3.1.3 on 2020-12-26 06:49 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('planning', '0007_planparticipant_isdutyseen'), ] operations = [ migrations.AddField( model_name='planparticipant', name='role', field=models.CharField(max_length=40, null=True, verbose_name='role'), ), ]
{"/src/planning/forms.py": ["/src/planning/models.py"], "/src/planning/views.py": ["/src/planning/forms.py", "/src/planning/models.py"], "/src/planning/templatetags/custom_tags.py": ["/src/planning/models.py"], "/src/participation/views.py": ["/src/participation/models.py"]}
42,115,605
Nozima29/django-Timer
refs/heads/master
/mytimer/migrations/0001_initial.py
# Generated by Django 3.1.7 on 2021-03-03 20:35 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Timer', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('start', models.PositiveIntegerField(verbose_name='Timer start')), ('end', models.PositiveIntegerField(verbose_name='Timer end')), ], options={ 'verbose_name': 'Timer', 'verbose_name_plural': 'Timers', }, ), ]
{"/mytimer/forms.py": ["/mytimer/models.py"], "/mytimer/tests.py": ["/mytimer/forms.py", "/mytimer/models.py"], "/mytimer/urls.py": ["/mytimer/views.py"], "/mytimer/apps.py": ["/mytimer/models.py"], "/mytimer/views.py": ["/mytimer/forms.py", "/mytimer/models.py"]}
42,115,606
Nozima29/django-Timer
refs/heads/master
/mytimer/migrations/0002_auto_20210304_0412.py
# Generated by Django 3.1.7 on 2021-03-03 23:12 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('mytimer', '0001_initial'), ] operations = [ migrations.AlterField( model_name='timer', name='end', field=models.PositiveIntegerField(blank=True, null=True), ), migrations.AlterField( model_name='timer', name='start', field=models.PositiveIntegerField(), ), ]
{"/mytimer/forms.py": ["/mytimer/models.py"], "/mytimer/tests.py": ["/mytimer/forms.py", "/mytimer/models.py"], "/mytimer/urls.py": ["/mytimer/views.py"], "/mytimer/apps.py": ["/mytimer/models.py"], "/mytimer/views.py": ["/mytimer/forms.py", "/mytimer/models.py"]}
42,174,905
mateusfiori/tag2bio
refs/heads/main
/tag2bio/Bio2Tag.py
class Bio2Tag: """ Class responsible converting tag format annotated text to BIO format annotated text Attributes: text (str): The text that will be converted """ def __init__(self, text: str='') -> None: self.text: str = text self.parsed_text: str = '' def _prepare_token(self, token_list: list) -> list: """ Private function to handle the BIO formatting Args: token_list (list): list of BIO token lines Returns: list: list of ready to print tokens """ prepared_token_list = list() len_token_list = len(token_list) for i, token in enumerate(token_list): token_split = token.split(' ') next_token = ['', ''] if i == len_token_list-1 else token_list[i+1].split(' ') if len(token_split) < 2: prepared_token_list.append(token_split[0]) elif token_split[1][0] == 'B' and next_token[1][0] == 'I': prepared_token_list.append(f'<{token_split[1][2:]}> {token_split[0]}') elif token_split[1][0] == 'I' and next_token[1][0] != 'I': prepared_token_list.append(f'{token_split[0]} </{token_split[1][2:]}>') elif token_split[1][0] == 'B' and next_token[1][0] != 'I': prepared_token_list.append(f'<{token_split[1][2:]}> {token_split[0]} </{token_split[1][2:]}>') else: prepared_token_list.append(token_split[0]) return prepared_token_list def parse(self) -> str: """ Function to parse text from BIO format to tag format Args: None Returns: str: parsed text in tag format """ splitted_text = self.text.split('\n') self.parsed_text = ' '.join(self._prepare_token(splitted_text)) return self.parsed_text def save(self, path: str='./tag_output.txt') -> None: """ Function to save the parsed text to a file Args: path (str): path where the file will be saved Returns: None """ with open(path, 'w') as f: f.write(self.parsed_text)
{"/tag2bio/__init__.py": ["/tag2bio/Tag2Bio.py", "/tag2bio/Bio2Tag.py"], "/playground.py": ["/tag2bio/__init__.py"]}
42,174,906
mateusfiori/tag2bio
refs/heads/main
/tag2bio/Tag2Bio.py
from bs4 import BeautifulSoup class Tag2Bio: """ Class responsible converting tag format annotated text to BIO format annotated text Attributes: text (str): The text that will be converted """ def __init__(self, text: str='') -> None: self.text: str = text self.soup: BeautifulSoup = BeautifulSoup( self.text, features='html.parser' ) self.parsed_text: str = '' def parse(self) -> str: """ Function to parse text from tag format to BIO format Args: None Returns: str: parsed text in BIO format """ clean_text: str = self.soup.get_text() # It's a long story... clean_text = clean_text.replace('.', ' .') clean_text_split: list = clean_text.split() aux_structure: list = [['O', '']] * len(clean_text.split()) tag_infos: list = [ (''.join(tag.find_all(text=True)), tag.name) for tag in self.soup.find_all() ] for txt_to_search, tag_name in tag_infos: token_qty: int = len(txt_to_search.split()) for idx in range(len(clean_text_split) - token_qty+1): if clean_text_split[idx : idx+token_qty] == txt_to_search.split(): aux_structure[idx] = ['B', tag_name] aux_structure[idx+1 : idx+token_qty] = [['I', tag_name]] * (token_qty-1) break for token, (bio_tag, tag_name) in zip(clean_text_split, aux_structure): separator = '-' if bio_tag != 'O' else ' ' self.parsed_text += f'{token} {bio_tag}{separator}{tag_name.lower()}\n' return self.parsed_text def save(self, path: str='./bio_output.txt') -> None: """ Function to save the parsed text to a file Args: path (str): path where the file will be saved Returns: None """ with open(path, 'w') as f: f.write(self.parsed_text)
{"/tag2bio/__init__.py": ["/tag2bio/Tag2Bio.py", "/tag2bio/Bio2Tag.py"], "/playground.py": ["/tag2bio/__init__.py"]}
42,174,907
mateusfiori/tag2bio
refs/heads/main
/playground.py
from tag2bio import Tag2Bio, Bio2Tag def main(): text = """My name is <name>John Doe</name>. and this is just an example for the demonstration in <country>Brazil</country>. """ output_path = './output.txt' tb = Tag2Bio(text) parsed = tb.parse() print(parsed) # tb.save(output_path) bt = Bio2Tag(parsed) bio_parsed = bt.parse() print(bio_parsed) bt.save() if __name__ == '__main__': main()
{"/tag2bio/__init__.py": ["/tag2bio/Tag2Bio.py", "/tag2bio/Bio2Tag.py"], "/playground.py": ["/tag2bio/__init__.py"]}
42,174,908
mateusfiori/tag2bio
refs/heads/main
/tag2bio/__init__.py
from .Tag2Bio import Tag2Bio from .Bio2Tag import Bio2Tag
{"/tag2bio/__init__.py": ["/tag2bio/Tag2Bio.py", "/tag2bio/Bio2Tag.py"], "/playground.py": ["/tag2bio/__init__.py"]}
42,174,909
mateusfiori/tag2bio
refs/heads/main
/setup.py
from setuptools import setup setup(name='tag2bio', version='0.4', description='A package created for translating tag formatted text to BIO formatted text.', packages=['tag2bio'], install_requires=['beautifulsoup4==4.10.0'], zip_safe=False )
{"/tag2bio/__init__.py": ["/tag2bio/Tag2Bio.py", "/tag2bio/Bio2Tag.py"], "/playground.py": ["/tag2bio/__init__.py"]}
42,236,761
alexgorin/gymai
refs/heads/main
/ai/qdl/training.py
from dataclasses import dataclass, field from typing import Dict, List, Tuple import gym import numpy as np import pandas as pd import tensorflow as tf from ai.common.agent import ExplorerFactory from ai.common.env_runner import EnvRunner from ai.common.history import History, HistoryColumns from ai.common.utils import to_array_of_lists from ai.qdl.agent import QLAgent def init_q_values_nearest_terminal(history_sample: pd.DataFrame, actions_count: int) -> np.ndarray: avg_step_distance = np.mean(history_sample[ [HistoryColumns.OBSERVATION.name, HistoryColumns.NEXT_OBSERVATION.name] ].apply( lambda row: np.linalg.norm(row[HistoryColumns.OBSERVATION.name] - row[HistoryColumns.NEXT_OBSERVATION.name]), axis=1, )) avg_reward_per_step = np.mean(history_sample[[HistoryColumns.REWARD.name]])[HistoryColumns.REWARD.name] avg_reward_per_distance = avg_reward_per_step / avg_step_distance terminals = history_sample[history_sample[HistoryColumns.DONE.name] == True][ [HistoryColumns.NEXT_OBSERVATION.name, HistoryColumns.REWARD.name] ] rewards_to_nearest_terminal = history_sample[[ HistoryColumns.OBSERVATION.name, HistoryColumns.DONE.name, HistoryColumns.REWARD.name ]].apply( _reward_to_nearest_terminal, args=(terminals, actions_count, avg_reward_per_distance, False), axis=1, ) rewards_to_nearest_terminal_next = history_sample[[ HistoryColumns.NEXT_OBSERVATION.name, HistoryColumns.DONE.name, HistoryColumns.REWARD.name ]].apply( _reward_to_nearest_terminal, args=(terminals, actions_count, avg_reward_per_distance, True), axis=1, ) return rewards_to_nearest_terminal, rewards_to_nearest_terminal_next def _reward_to_nearest_terminal( row, terminals: pd.DataFrame, actions_count: int, avg_reward_per_distance: float, is_next_observation: bool ) -> List[float]: observation, done, reward = row if done and is_next_observation: return [reward] * actions_count distance, terminal_reward = min( terminals.apply( lambda row: (np.linalg.norm(observation - row[0]), row[1]), axis=1 ), key=lambda row: row[0] ) return [ terminal_reward + distance * avg_reward_per_distance ] * actions_count def init_q_values_path_to_terminal(history_sample: pd.DataFrame, actions_count: int) -> Tuple[np.ndarray, np.ndarray]: """Requires sample of consequent moves, not randomized""" rewards = [] for row_index in reversed(range(len(history_sample.index))): observation, action, reward, next_observation, done = history_sample.iloc[row_index] if done or row_index == len(history_sample.index) - 1: rewards.append(( [reward] * actions_count, [0] * actions_count )) else: next_observation_reward = rewards[-1][0][0] rewards.append( ([next_observation_reward + reward] * actions_count, [next_observation_reward] * actions_count) ) return tuple(zip(*reversed(rewards))) @dataclass class Trainer: model: tf.keras.Model model_fit_args: Dict sample_size: int = 1000 discount: float = 0.99 target_model_update_period = 5 target_model: tf.keras.Model = field(init=False) count_till_target_model_update: int = field(default=0, init=False) initial_epoch: int = field(default=0, init=False) def __post_init__(self): self.target_model = tf.keras.models.clone_model(self.model) def update_target_model(self): if self.count_till_target_model_update == 0: self.target_model.set_weights(self.model.get_weights()) self.count_till_target_model_update = self.target_model_update_period else: self.count_till_target_model_update -= 1 def _is_first_iteration(self) -> bool: return self.initial_epoch == 0 def train_iteration(self, history: History): data_sample = history.data() if self._is_first_iteration() else self._sample_history(history) # (len(data_sample.index), observation_size) observations = data_sample.apply( lambda row: row[HistoryColumns.OBSERVATION], axis=1, result_type='expand') # (len(data_sample.index), observation_size) next_observations = data_sample.apply( lambda row: row[HistoryColumns.NEXT_OBSERVATION], axis=1, result_type='expand') if self._is_first_iteration(): actions_count = self.model.output_shape[1] data_sample['predicted_q_values'], data_sample['predicted_q_values_next'] = init_q_values_path_to_terminal( data_sample, actions_count) else: data_sample['predicted_q_values'] = to_array_of_lists(self.target_model.predict(observations)) data_sample['predicted_q_values_next'] = to_array_of_lists(self.target_model.predict(next_observations)) # (len(data_sample.index), action_count) adjusted_q_values = data_sample.apply(self._adjusted_q_values, axis=1, result_type='expand') training_history = self.model.fit(observations, adjusted_q_values, **self._set_epoch_values()) self.initial_epoch += len(training_history.epoch) self.update_target_model() def _set_epoch_values(self) -> Dict: """ Adjusting the epoch indices for tensorboard """ epochs = self.model_fit_args.get('epochs', 1) fit_args = { **self.model_fit_args, **{ 'initial_epoch': self.initial_epoch, 'epochs': epochs + self.initial_epoch, } } return fit_args def _adjusted_q_values(self, row) -> np.ndarray: observation, action, reward, next_observation, done, predicted_q_value, predicted_q_value_next = row adjusted_q_value = list(predicted_q_value) if done: adjusted_q_value[action] = reward else: adjusted_q_value[action] = reward + self.discount * max(predicted_q_value_next) return adjusted_q_value def _sample_history(self, history: History) -> pd.DataFrame: df = history.data() terminal_state_observations = df.loc[df[HistoryColumns.DONE.name]][HistoryColumns.OBSERVATION.name] terminal_state_proximity_weights = df.apply( lambda row: self._terminal_state_proximity_weight(min(( self._distance(row[HistoryColumns.OBSERVATION], terminal_state_observation) for terminal_state_observation in terminal_state_observations) )), axis=1 ) return history.data().sample(self.sample_size, weights=terminal_state_proximity_weights).reset_index(drop=True) # return history.data().sample(self.sample_size).reset_index(drop=True) @staticmethod def _terminal_state_proximity_weight(distance_to_terminal_state: float) -> float: return 1 / (1 + distance_to_terminal_state) @staticmethod def _distance(values1: List, values2: List): return np.sqrt(sum((val1 - val2)**2 for val1, val2 in zip(values1, values2))) class TrainRunner(EnvRunner): def __init__( self, env: gym.Env, agent: QLAgent, render: bool, explorer_factory: ExplorerFactory, trainer: Trainer, history: History, file_writer, train_every: int = 1000, ): super().__init__(env, explorer_factory.explorer(agent), render) self.history = history self.trainer = trainer self.file_writer = file_writer self.train_every = train_every self.steps_till_training = self.train_every self._agent = agent def on_step(self, episode_index, step_index, observation): action, next_observation, reward, done, info = super().on_step(episode_index, step_index, observation) # reward = reward if not done else -1000 # Specific to CartPole-v0 world self.history.update(observation, action, reward, next_observation, done) self.steps_till_training -= 1 return action, next_observation, reward, done, info def on_done(self, episode_index, step_index, observation, action, next_observation, reward, done, info): if self.steps_till_training <= 0: if self.history.size() >= self.trainer.sample_size: self._log_to_tensorboard() print("Training") self.trainer.train_iteration(self.history) self.steps_till_training = self.train_every def _log_to_tensorboard(self): avg_reward, avg_step_count = self._performance() step = self.trainer.initial_epoch with self.file_writer.as_default(): tf.summary.scalar("Avg reward", avg_reward, step=step) tf.summary.scalar("Avg step count", avg_step_count, step=step) self.file_writer.flush() print(f"Avg steps count: {avg_step_count}, avg reward: {avg_reward}") def _prev_iteration_performance(self) -> Tuple[float, float]: episode_count, overall_steps_count, overall_reward = 0, 0, 0 for steps_count, reward in reversed(self.episode_reward_history): episode_count += 1 overall_steps_count += steps_count overall_reward += reward if overall_steps_count >= self.train_every: return overall_reward / episode_count, overall_steps_count / episode_count def _performance(self) -> Tuple[float, float]: test_env_runner = EnvRunner(self.env, self._agent, True) test_results = test_env_runner.run(10, 10000) episode_step_counts, episode_rewards = tuple(zip(*test_results)) return np.mean(episode_rewards), np.mean(episode_step_counts)
{"/ai/qdl/agent.py": ["/ai/common/agent.py"], "/ai/common/env_runner.py": ["/ai/common/agent.py"], "/ai/run.py": ["/ai/common/env_runner.py", "/ai/common/agent.py", "/ai/common/model.py", "/ai/common/history.py", "/ai/qdl/agent.py", "/ai/qdl/training.py"], "/ai/qdl/training.py": ["/ai/common/agent.py", "/ai/common/env_runner.py", "/ai/common/history.py", "/ai/common/utils.py", "/ai/qdl/agent.py"]}
42,236,762
alexgorin/gymai
refs/heads/main
/ai/common/history.py
from enum import IntEnum import pandas as pd class HistoryColumns(IntEnum): OBSERVATION = 0 ACTION = 1 REWARD = 2 NEXT_OBSERVATION = 3 DONE = 4 class History: def __init__(self, max_row_count: int = 100000): self._columns = [c.name for c in HistoryColumns] self._data = pd.DataFrame(columns=self._columns) self._max_row_count = max_row_count def update(self, observation, action, reward, next_observation, done): self._data = self._data.append( dict(zip(self._columns, [observation, action, reward, next_observation, done])), ignore_index=True )[-self._max_row_count:] def data(self) -> pd.DataFrame: return self._data def size(self) -> int: return len(self.data().index)
{"/ai/qdl/agent.py": ["/ai/common/agent.py"], "/ai/common/env_runner.py": ["/ai/common/agent.py"], "/ai/run.py": ["/ai/common/env_runner.py", "/ai/common/agent.py", "/ai/common/model.py", "/ai/common/history.py", "/ai/qdl/agent.py", "/ai/qdl/training.py"], "/ai/qdl/training.py": ["/ai/common/agent.py", "/ai/common/env_runner.py", "/ai/common/history.py", "/ai/common/utils.py", "/ai/qdl/agent.py"]}
42,236,763
alexgorin/gymai
refs/heads/main
/ai/common/utils.py
from typing import List import numpy as np def to_array_of_lists(a: np.ndarray) -> List: col_count = a.shape[1] result = [list(e) for e in zip(*(a[:, col_index] for col_index in range(col_count)))] return result
{"/ai/qdl/agent.py": ["/ai/common/agent.py"], "/ai/common/env_runner.py": ["/ai/common/agent.py"], "/ai/run.py": ["/ai/common/env_runner.py", "/ai/common/agent.py", "/ai/common/model.py", "/ai/common/history.py", "/ai/qdl/agent.py", "/ai/qdl/training.py"], "/ai/qdl/training.py": ["/ai/common/agent.py", "/ai/common/env_runner.py", "/ai/common/history.py", "/ai/common/utils.py", "/ai/qdl/agent.py"]}
42,238,704
Fel-gaetea/TavMartcom
refs/heads/main
/Martcom/sesion/urls.py
from django.urls import path from . import views urlpatterns = [ path('signup/',views.SignUp.as_view(), name="sigup"), ]
{"/Martcom/catalogo/views.py": ["/Martcom/catalogo/models.py"]}
42,287,761
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_menu.py
from aldryn_apphooks_config.utils import get_app_instance from django.utils.translation import activate from menus.menu_pool import menu_pool from parler.utils.context import smart_override, switch_language from djangocms_blog.cms_appconfig import BlogConfig from djangocms_blog.models import BlogCategory from djangocms_blog.settings import MENU_TYPE_CATEGORIES, MENU_TYPE_COMPLETE, MENU_TYPE_NONE, MENU_TYPE_POSTS from djangocms_blog.views import CategoryEntriesView, PostDetailView from .base import BaseTest class MenuTest(BaseTest): cats = [] def setUp(self): super().setUp() self.cats = [self.category_1] for _i, lang_data in enumerate(self._categories_data): cat = self._get_category(lang_data["en"]) if "it" in lang_data: cat = self._get_category(lang_data["it"], cat, "it") self.cats.append(cat) activate("en") self._reload_menus() def test_menu_cache_clear_blogconfig(self): """ Tests if menu cache is cleared after config deletion """ from django.core.cache import cache from menus.models import CacheKey pages = self.get_pages() self.get_posts() self.reload_urlconf() app_config_test = BlogConfig.objects.create(namespace="test_config") app_config_test.app_title = "appx" app_config_test.object_name = "Blogx" app_config_test.save() lang = "en" with smart_override(lang): self._reset_menus() request = self.get_page_request(pages[1], self.user, pages[1].get_absolute_url(lang), edit=True) self.get_nodes(menu_pool, request) keys = CacheKey.objects.get_keys().distinct().values_list("key", flat=True) self.assertTrue(cache.get_many(keys)) app_config_test.delete() self.assertFalse(cache.get_many(keys)) def test_menu_cache_clear_category(self): """ Tests if menu cache is cleared after category deletion """ from django.core.cache import cache from menus.models import CacheKey pages = self.get_pages() self.get_posts() self.reload_urlconf() lang = "en" with smart_override(lang): self._reset_menus() request = self.get_page_request(pages[1], self.user, pages[1].get_absolute_url(lang), edit=True) self.get_nodes(menu_pool, request) keys = CacheKey.objects.get_keys().distinct().values_list("key", flat=True) self.assertTrue(cache.get_many(keys)) category_test = BlogCategory.objects.create(name="category test", app_config=self.app_config_1) category_test.set_current_language("it", initialize=True) category_test.name = "categoria test" category_test.save() self.assertFalse(cache.get_many(keys)) self.get_nodes(menu_pool, request) keys = CacheKey.objects.get_keys().distinct().values_list("key", flat=True) self.assertTrue(cache.get_many(keys)) category_test.delete() self.assertFalse(cache.get_many(keys)) keys = CacheKey.objects.get_keys().distinct().values_list("key", flat=True) self.assertFalse(keys) def test_menu_nodes(self): """ Tests if all categories are present in the menu """ pages = self.get_pages() posts = self.get_posts() self.reload_urlconf() for lang in ("en", "it"): with smart_override(lang): self._reset_menus() request = self.get_page_request(pages[1], self.user, pages[1].get_absolute_url(lang), edit=True) nodes = self.get_nodes(menu_pool, request) self.assertTrue(len(nodes), BlogCategory.objects.all().count() + len(pages)) nodes_url = {node.get_absolute_url() for node in nodes} cats_url = {cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)} self.assertTrue(cats_url.issubset(nodes_url)) self._reset_menus() posts[0].categories.clear() for lang in ("en", "it"): with smart_override(lang): self._reset_menus() request = self.get_page_request( pages[1].get_draft_object(), self.user, pages[1].get_draft_object().get_absolute_url(lang) ) nodes = self.get_nodes(menu_pool, request) nodes_url = [node.get_absolute_url() for node in nodes] self.assertTrue(len(nodes_url), BlogCategory.objects.all().count() + len(pages)) self.assertFalse(posts[0].get_absolute_url(lang) in nodes_url) self.assertTrue(posts[1].get_absolute_url(lang) in nodes_url) def test_menu_options(self): """ Tests menu structure based on menu_structure configuration """ self.get_pages() posts = self.get_posts() cats_url = {} cats_with_post_url = {} cats_without_post_url = {} posts_url = {} languages = ("en", "it") for lang in languages: with smart_override(lang): self._reset_menus() cats_url[lang] = {cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)} cats_with_post_url[lang] = { cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang) and cat.blog_posts.published().exists() } cats_without_post_url[lang] = cats_url[lang].difference(cats_with_post_url[lang]) posts_url[lang] = { post.get_absolute_url(lang) for post in posts if post.has_translation(lang) and post.app_config == self.app_config_1 } # No item in the menu self.app_config_1.app_data.config.menu_structure = MENU_TYPE_NONE self.app_config_1.save() self._reset_menus() for lang in languages: request = self.get_page_request(None, self.user, r"/%s/page-two/" % lang) with smart_override(lang): self._reset_menus() nodes = self.get_nodes(menu_pool, request) nodes_url = {node.get_absolute_url() for node in nodes} self.assertFalse(cats_url[lang].issubset(nodes_url)) self.assertFalse(posts_url[lang].issubset(nodes_url)) # Only posts in the menu self.app_config_1.app_data.config.menu_structure = MENU_TYPE_POSTS self.app_config_1.save() self._reset_menus() for lang in languages: request = self.get_page_request(None, self.user, r"/%s/page-two/" % lang) with smart_override(lang): self._reset_menus() nodes = self.get_nodes(menu_pool, request) nodes_url = {node.get_absolute_url() for node in nodes} self.assertFalse(cats_url[lang].issubset(nodes_url)) self.assertTrue(posts_url[lang].issubset(nodes_url)) # Only categories in the menu self.app_config_1.app_data.config.menu_structure = MENU_TYPE_CATEGORIES self.app_config_1.save() self._reset_menus() for lang in languages: request = self.get_page_request(None, self.user, r"/%s/page-two/" % lang) with smart_override(lang): self._reset_menus() nodes = self.get_nodes(menu_pool, request) nodes_url = {node.get_absolute_url() for node in nodes} self.assertTrue(cats_url[lang].issubset(nodes_url)) self.assertFalse(posts_url[lang].issubset(nodes_url)) # Both types in the menu self.app_config_1.app_data.config.menu_structure = MENU_TYPE_COMPLETE self.app_config_1.save() self._reset_menus() for lang in languages: request = self.get_page_request(None, self.user, r"/%s/page-two/" % lang) with smart_override(lang): self._reset_menus() nodes = self.get_nodes(menu_pool, request) nodes_url = {node.get_absolute_url() for node in nodes} self.assertTrue(cats_url[lang].issubset(nodes_url)) self.assertTrue(posts_url[lang].issubset(nodes_url)) # Both types in the menu self.app_config_1.app_data.config.menu_empty_categories = False self.app_config_1.save() self.app_config_2.app_data.config.menu_empty_categories = False self.app_config_2.save() self._reset_menus() for lang in languages: request = self.get_page_request(None, self.user, r"/%s/page-two/" % lang) with smart_override(lang): self._reset_menus() nodes = self.get_nodes(menu_pool, request) nodes_url = {node.url for node in nodes} self.assertTrue(cats_with_post_url[lang].issubset(nodes_url)) self.assertFalse(cats_without_post_url[lang].intersection(nodes_url)) self.assertTrue(posts_url[lang].issubset(nodes_url)) # Both types in the menu self.app_config_1.app_data.config.menu_empty_categories = True self.app_config_1.save() self.app_config_2.app_data.config.menu_empty_categories = True self.app_config_2.save() self._reset_menus() def test_modifier(self): """ Tests if correct category is selected in the menu according to context (view object) """ pages = self.get_pages() posts = self.get_posts() tests = ( # view class, view kwarg, view object, category (PostDetailView, "slug", posts[0], posts[0].categories.first()), (CategoryEntriesView, "category", self.cats[2], self.cats[2]), ) self.app_config_1.app_data.config.menu_structure = MENU_TYPE_COMPLETE self.app_config_1.save() for view_cls, kwarg, obj, _cat in tests: with smart_override("en"): with switch_language(obj, "en"): request = self.get_page_request(pages[1], self.user, path=obj.get_absolute_url()) self._reset_menus() menu_pool.clear(all=True) view_obj = view_cls() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.app_config = self.app_config_1 view_obj.kwargs = {kwarg: obj.slug} view_obj.get(request) view_obj.get_context_data() # check if selected menu node points to cat nodes = self.get_nodes(menu_pool, request) found = [] for node in nodes: if node.selected: found.append(node.get_absolute_url()) self.assertTrue(obj.get_absolute_url() in found) self.app_config_1.app_data.config.menu_structure = MENU_TYPE_CATEGORIES self.app_config_1.save() for view_cls, kwarg, obj, cat in tests: with smart_override("en"): with switch_language(obj, "en"): request = self.get_page_request(pages[1], self.user, path=obj.get_absolute_url()) self._reset_menus() menu_pool.clear(all=True) view_obj = view_cls() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.app_config = self.app_config_1 view_obj.kwargs = {kwarg: obj.slug} view_obj.get(request) view_obj.get_context_data() # check if selected menu node points to cat nodes = self.get_nodes(menu_pool, request) found = [node.get_absolute_url() for node in nodes if node.selected] self.assertTrue(cat.get_absolute_url() in found) self.app_config_1.app_data.config.menu_structure = MENU_TYPE_COMPLETE self.app_config_1.save()
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,762
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_utils/blog_urls.py
from django.urls import path from djangocms_blog.feeds import FBInstantArticles, LatestEntriesFeed, TagFeed from djangocms_blog.settings import get_setting from djangocms_blog.views import ( AuthorEntriesView, CategoryEntriesView, PostArchiveView, PostDetailView, PostListView, TaggedListView, ) def get_urls(): urls = get_setting("PERMALINK_URLS") details = [] for urlconf in urls.values(): details.append( path(urlconf, PostDetailView.as_view(), name="post-detail"), ) return details detail_urls = get_urls() urlpatterns = [ path("latests/", PostListView.as_view(), name="posts-latest"), path("feed/", LatestEntriesFeed(), name="posts-latest-feed"), path("feed/fb/", FBInstantArticles(), name="posts-latest-feed-fb"), path("<int:year>/", PostArchiveView.as_view(), name="posts-archive"), path("<int:year>/<int:month>/", PostArchiveView.as_view(), name="posts-archive"), path("author/<str:username>/", AuthorEntriesView.as_view(), name="posts-author"), path("category/<str:category>/", CategoryEntriesView.as_view(), name="posts-category"), path("tag/<slug:tag>/", TaggedListView.as_view(), name="posts-tagged"), path("tag/<slug:tag>/feed/", TagFeed(), name="posts-tagged-feed"), ] + detail_urls
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,763
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_utils/urls.py
import sys from cms.sitemaps import CMSSitemap from django.conf import settings from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.contrib.sitemaps.views import sitemap from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import include, path from django.views.i18n import JavaScriptCatalog from django.views.static import serve from djangocms_blog.sitemaps import BlogSitemap admin.autodiscover() urlpatterns = [ path("media/<str:path>", serve, {"document_root": settings.MEDIA_ROOT, "show_indexes": True}), path("jsi18n/", JavaScriptCatalog.as_view(), name="javascript-catalog"), path("taggit_autosuggest/", include("taggit_autosuggest.urls")), path("sitemap.xml", sitemap, {"sitemaps": {"cmspages": CMSSitemap, "blog": BlogSitemap}}), ] urlpatterns += staticfiles_urlpatterns() if "server" not in sys.argv: urlpatterns += i18n_patterns( path("blog/", include("djangocms_blog.urls")), ) urlpatterns += i18n_patterns( path("admin/", admin.site.urls), path("", include("cms.urls")), )
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,764
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_liveblog.py
from datetime import timedelta import pytest from channels.db import database_sync_to_async from channels.testing import WebsocketCommunicator from cms.api import add_plugin from django.test import RequestFactory from django.utils.lorem_ipsum import words from django.utils.timezone import now from djangocms_blog.cms_appconfig import BlogConfig from djangocms_blog.liveblog.models import Liveblog from djangocms_blog.models import Post from djangocms_blog.settings import DATE_FORMAT from .base import BaseTest from .test_utils.routing import application async def _connect(post): path = "liveblog/{namespace}/{lang}/{slug}/".format( namespace=post.app_config.namespace, lang=post.get_current_language(), slug=post.slug, ) communicator = WebsocketCommunicator(application, path) connected, __ = await communicator.connect() assert connected assert await communicator.receive_nothing() is True return communicator def get_request(path="/"): factory = RequestFactory() request = factory.get(path) return request @database_sync_to_async def get_post(): config, __ = BlogConfig.objects.get_or_create(namespace="bla_bla_bla") post_data = {"title": words(count=3, common=False), "app_config": config} post = Post.objects.create(**post_data) post.enable_liveblog = True post.save() return post @database_sync_to_async def delete_post(post): post.app_config.delete() post.delete() @database_sync_to_async def add_livelobg_plugin(placeholder, publish=True): plugin_text = words(count=3, common=False) plugin = add_plugin(placeholder, "LiveblogPlugin", language="en", body=plugin_text, publish=publish) __, admin = plugin.get_plugin_instance() admin.save_model(get_request("/"), plugin, None, None) return plugin, admin, plugin_text @database_sync_to_async def update_livelobg_plugin_content(plugin, publish=True): plugin_text = words(count=3, common=False) plugin.body = plugin_text plugin.publish = publish plugin.save() __, admin = plugin.get_plugin_instance() admin.save_model(get_request("/"), plugin, None, None) return plugin, admin, plugin_text @pytest.mark.debug @pytest.mark.django_db @pytest.mark.asyncio async def test_add_plugin(): post = await get_post() communicator = await _connect(post) plugin, admin, plugin_text = await add_livelobg_plugin(post.liveblog) rendered = await communicator.receive_json_from() assert plugin.pk == rendered["id"] assert plugin.creation_date.strftime(DATE_FORMAT) == rendered["creation_date"] assert plugin.changed_date.strftime(DATE_FORMAT) == rendered["changed_date"] assert rendered["content"].find('data-post-id="{}"'.format(plugin.pk)) > -1 assert rendered["content"].find(plugin_text) > -1 plugin, admin, new_plugin_text = await update_livelobg_plugin_content(plugin) rendered = await communicator.receive_json_from() assert plugin.pk == rendered["id"] assert plugin.creation_date.strftime(DATE_FORMAT) == rendered["creation_date"] assert plugin.changed_date.strftime(DATE_FORMAT) == rendered["changed_date"] assert rendered["content"].find('data-post-id="{}"'.format(plugin.pk)) > -1 assert rendered["content"].find(new_plugin_text) > -1 assert rendered["content"].find(plugin_text) == -1 await communicator.disconnect() await delete_post(post) @pytest.mark.skip @pytest.mark.django_db @pytest.mark.asyncio async def test_add_plugin_no_publish(): post = await get_post() communicator = await _connect(post) plugin, admin, plugin_text = await add_livelobg_plugin(post.liveblog, publish=False) assert await communicator.receive_nothing() is True await communicator.send_json_to({"hello": "world"}) rendered = await communicator.receive_json_from() plugin, admin, new_plugin_text = await update_livelobg_plugin_content(plugin, publish=True) rendered = await communicator.receive_json_from() assert plugin.pk == rendered["id"] assert plugin.creation_date.strftime(DATE_FORMAT) == rendered["creation_date"] assert plugin.changed_date.strftime(DATE_FORMAT) == rendered["changed_date"] assert rendered["content"].find('data-post-id="{}"'.format(plugin.pk)) > -1 assert rendered["content"].find(new_plugin_text) > -1 assert rendered["content"].find(plugin_text) == -1 await communicator.disconnect() await delete_post(post) @pytest.mark.skip @pytest.mark.django_db @pytest.mark.asyncio async def test_disconnect(): post = await get_post() communicator = await _connect(post) plugin, admin, plugin_text = await add_livelobg_plugin(post.liveblog) rendered = await communicator.receive_json_from() assert rendered["content"] await communicator.disconnect() await update_livelobg_plugin_content(plugin) assert await communicator.receive_nothing() is True await delete_post(post) @pytest.mark.django_db @pytest.mark.asyncio async def test_nopost(): post = await get_post() post.slug = "something" communicator = await _connect(post) assert await communicator.receive_nothing() is True await communicator.disconnect() await delete_post(post) @pytest.mark.django_db @pytest.mark.asyncio async def test_plugin_not_liveblog_placeholder(): @database_sync_to_async def get_group(plugin): return plugin.liveblog_group post = await get_post() communicator = await _connect(post) plugin, _admin, _plugin_text = await add_livelobg_plugin(post.content) liveblog_group = await get_group(plugin) assert liveblog_group is None assert await communicator.receive_nothing() is True await communicator.disconnect() await delete_post(post) class LiveBlogTest(BaseTest): def setUp(self): Liveblog.objects.all().delete() super().setUp() def test_plugin_render(self): pages = self.get_pages() posts = self.get_posts() post = posts[0] post.enable_liveblog = True post.save() plugin = add_plugin(post.liveblog, "LiveblogPlugin", language="en", body="live text", publish=False) rendered = self.render_plugin(pages[0], "en", plugin, edit=False) self.assertFalse(rendered.strip()) plugin.publish = True plugin.save() rendered = self.render_plugin(pages[0], "en", plugin, edit=False) self.assertTrue(rendered.find('data-post-id="{}"'.format(plugin.pk)) > -1) self.assertTrue(rendered.find("live text") > -1) def test_plugins_order(self): self.get_pages() posts = self.get_posts() post = posts[0] post.enable_liveblog = True post.save() current_date = now() plugin_1 = add_plugin( post.liveblog, "LiveblogPlugin", language="en", body="plugin 1", publish=True, post_date=current_date - timedelta(seconds=1), ) plugin_2 = add_plugin( post.liveblog, "LiveblogPlugin", language="en", body="plugin 2", publish=True, post_date=current_date - timedelta(seconds=5), ) plugin_3 = add_plugin( post.liveblog, "LiveblogPlugin", language="en", body="plugin 3", publish=True, post_date=current_date - timedelta(seconds=10), ) self.assertEqual( list(Liveblog.objects.all().order_by("position").values_list("pk", flat=True)), [plugin_1.pk, plugin_2.pk, plugin_3.pk], ) plugin_1.post_date = current_date - timedelta(seconds=20) plugin_1.save() self.assertEqual( list(Liveblog.objects.all().order_by("position").values_list("pk", flat=True)), [plugin_2.pk, plugin_3.pk, plugin_1.pk], )
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,765
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_utils/migrations/0002_auto_20200516_1230.py
# Generated by Django 2.2 on 2020-05-16 10:30 import cms.models.fields import django.contrib.auth.models import django.contrib.auth.validators import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("cms", "0022_auto_20180620_1551"), ("djangocms_blog", "0039_auto_20200331_2227"), ("test_utils", "0001_initial"), ] operations = [ migrations.AlterModelManagers( name="customuser", managers=[ ("objects", django.contrib.auth.models.UserManager()), ], ), migrations.AlterField( model_name="customuser", name="last_name", field=models.CharField(blank=True, max_length=150, verbose_name="last name"), ), migrations.AlterField( model_name="customuser", name="username", field=models.CharField( error_messages={"unique": "A user with that username already exists."}, help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.", max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name="username", ), ), migrations.CreateModel( name="PostPlaceholderExtension", fields=[ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ( "post", models.OneToOneField( on_delete=django.db.models.deletion.CASCADE, related_name="placeholder", to="djangocms_blog.Post", ), ), ( "some_placeholder", cms.models.fields.PlaceholderField( editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name="some_placeholder", slotname="some_placeholder", to="cms.Placeholder", ), ), ], ), migrations.CreateModel( name="PostExtension", fields=[ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("some_field", models.CharField(max_length=10)), ( "post", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="extension", to="djangocms_blog.Post" ), ), ], ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,766
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0039_auto_20200331_2227.py
# Generated by Django 2.2.11 on 2020-03-31 20:27 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0038_post_media"), ] operations = [ migrations.AlterField( model_name="blogcategorytranslation", name="name", field=models.CharField(max_length=752, verbose_name="name"), ), migrations.AlterField( model_name="blogcategorytranslation", name="slug", field=models.SlugField(blank=True, max_length=752, verbose_name="slug"), ), migrations.AlterField( model_name="posttranslation", name="slug", field=models.SlugField(allow_unicode=True, blank=True, max_length=752, verbose_name="slug"), ), migrations.AlterField( model_name="posttranslation", name="title", field=models.CharField(max_length=752, verbose_name="title"), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,767
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_toolbar.py
from cms.toolbar.items import ButtonList, ModalItem from django.urls import reverse from django.utils.encoding import force_str from djangocms_blog.models import BLOG_CURRENT_POST_IDENTIFIER from .base import BaseTest class ToolbarTest(BaseTest): def test_toolbar_with_items(self): """ Test that Blog toolbar is present and contains all items """ from cms.toolbar.toolbar import CMSToolbar posts = self.get_posts() pages = self.get_pages() request = self.get_page_request(pages[0], self.user, r"/en/blog/", edit=True) setattr(request, BLOG_CURRENT_POST_IDENTIFIER, posts[0]) posts[0].publish = False posts[0].save() toolbar = CMSToolbar(request) toolbar.populate() toolbar.post_template_populate() toolbar.get_left_items() blog_menu = toolbar.menus["djangocms_blog"] self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse("admin:djangocms_blog_post_changelist"))), 1) self.assertEqual( len(blog_menu.find_items(ModalItem, url=reverse("admin:djangocms_blog_blogcategory_changelist"))), 1, ) self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse("admin:taggit_tag_changelist"))), 1) self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse("admin:djangocms_blog_post_add"))), 1) self.assertEqual( len(blog_menu.find_items(ModalItem, url=reverse("admin:djangocms_blog_post_change", args=(posts[0].pk,)))), 1, ) # Publish button only appears if current post is unpublished right = toolbar.get_right_items() buttons = sum((item.buttons for item in right if isinstance(item, ButtonList)), []) self.assertTrue([button for button in buttons if force_str(button.name) == "Publish Blog now"]) # Publish button does not appears if current post is published posts[0].publish = True posts[0].save() toolbar = CMSToolbar(request) toolbar.populate() toolbar.post_template_populate() right = toolbar.get_right_items() buttons = sum((item.buttons for item in right if isinstance(item, ButtonList)), []) self.assertFalse([button for button in buttons if force_str(button.name) == "Publish Blog now"]) # Publish button does not appears if other posts but the current one are unpublished posts[1].publish = True posts[1].save() toolbar = CMSToolbar(request) toolbar.populate() toolbar.post_template_populate() right = toolbar.get_right_items() buttons = sum((item.buttons for item in right if isinstance(item, ButtonList)), []) self.assertFalse([button for button in buttons if force_str(button.name) == "Publish Blog now"])
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,768
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/templatetags/djangocms_blog.py
from cms.utils.plugins import get_plugins from django import template register = template.Library() @register.simple_tag(name="media_plugins", takes_context=True) def media_plugins(context, post): """ Extract :py:class:`djangocms_blog.media.base.MediaAttachmentPluginMixin` plugins from the ``media`` placeholder of the provided post. They can be rendered with ``render_plugin`` templatetag: .. code-block: python {% media_plugins post as media_plugins %} {% for plugin in media_plugins %}{% render_plugin plugin %}{% endfor %} :param context: template context :type context: dict :param post: post instance :type post: :py:class:`djangocms_blog.models.Post` :return: list of :py:class:`djangocms_blog.media.base.MediaAttachmentPluginMixin` plugins :rtype: List[djangocms_blog.media.base.MediaAttachmentPluginMixin] """ request = context["request"] if post.media.get_plugins().exists(): return get_plugins(request, post.media, None) return [] @register.simple_tag(name="media_images", takes_context=True) def media_images(context, post, main=True): """ Extract images of the given size from all the :py:class:`djangocms_blog.media.base.MediaAttachmentPluginMixin` plugins in the ``media`` placeholder of the provided post. Support ``djangocms-video`` ``poster`` field in case the plugin does not implement ``MediaAttachmentPluginMixin`` API. Usage: .. code-block: python {% media_images post False as thumbs %} {% for thumb in thumbs %}<img src="{{ thumb }}/>{% endfor %} .. code-block: python {% media_images post as main_images %} {% for image in main_images %}<img src="{{ image }}/>{% endfor %} :param context: template context :type context: dict :param post: post instance :type post: :py:class:`djangocms_blog.models.Post` :param main: retrieve main image or thumbnail :type main: bool :return: list of images urls :rtype: list """ plugins = media_plugins(context, post) if main: image_method = "get_main_image" else: image_method = "get_thumb_image" images = [] for plugin in plugins: try: images.append(getattr(plugin, image_method)()) except Exception: try: image = plugin.poster if image: images.append(image.url) except AttributeError: pass return images
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,769
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_extension.py
from cms.api import add_plugin from django.contrib import admin from django.utils.encoding import force_str import djangocms_blog.admin from djangocms_blog.models import Post from .base import BaseTest from .test_utils.admin import PostExtensionInline from .test_utils.models import PostPlaceholderExtension class AddExtensionTest(BaseTest): def test_register_inline_extension(self): djangocms_blog.admin.register_extension(PostExtensionInline) djangocms_blog.admin.unregister_extension(PostExtensionInline) def test_register_placeholder_extension(self): djangocms_blog.admin.register_extension(PostPlaceholderExtension) djangocms_blog.admin.unregister_extension(PostPlaceholderExtension) def test_register_placeholder_extension_twice(self): djangocms_blog.admin.register_extension(PostPlaceholderExtension) with self.assertRaises(Exception): # noqa: B017 djangocms_blog.admin.register_extension(PostPlaceholderExtension) djangocms_blog.admin.unregister_extension(PostPlaceholderExtension) with self.assertRaises(Exception): # noqa: B017 djangocms_blog.admin.unregister_extension(PostPlaceholderExtension) def test_register_other(self): class X: pass with self.assertRaises(Exception): # noqa: B017 djangocms_blog.admin.register_extension(X) with self.assertRaises(Exception): # noqa: B017 djangocms_blog.admin.register_extension(X) def test_placeholder_object_auto_created(self): PostPlaceholderExtension.objects.all().delete() djangocms_blog.admin.register_extension(PostPlaceholderExtension) post = self._get_post(self._post_data[0]["en"]) PostPlaceholderExtension.objects.get(post=post) post.delete() djangocms_blog.admin.unregister_extension(PostPlaceholderExtension) def test_add_plugin_to_placeholder(self): djangocms_blog.admin.register_extension(PostPlaceholderExtension) pages = self.get_pages() ph = pages[0].placeholders.get(slot="some_placeholder") plugin = add_plugin(ph, "TextPlugin", language="en", body="<p>test</p>") rendered = self.render_plugin(pages[0], "en", plugin, edit=True) self.assertTrue(rendered.find("<p>test</p>") > -1) for page in pages: page.delete() djangocms_blog.admin.unregister_extension(PostPlaceholderExtension) def test_admin_post_views_should_have_extension(self): djangocms_blog.admin.register_extension(PostExtensionInline) self.get_pages() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) post = self._get_post(self._post_data[0]["en"]) # Add view should contain extension response = post_admin.add_view(request) response.render() self.assertRegex(force_str(response.content), r"<h2>.*PostExtension.*</h2>") # Changeview should contain extension response = post_admin.change_view(request, str(post.pk)) response.render() self.assertRegex(force_str(response.content), r"<h2>.*PostExtension.*</h2>") post.delete() djangocms_blog.admin.unregister_extension(PostExtensionInline) def test_admin_post_views_should_not_have_extension(self): djangocms_blog.admin.register_extension(PostExtensionInline) djangocms_blog.admin.unregister_extension(PostExtensionInline) self.get_pages() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) post = self._get_post(self._post_data[0]["en"]) # Add view should contain extension response = post_admin.add_view(request) response.render() self.assertNotRegex(force_str(response.content), r"<h2>.*PostExtension.*</h2>") # Changeview should contain extension response = post_admin.change_view(request, str(post.pk)) response.render() self.assertNotRegex(force_str(response.content), r"<h2>.*PostExtension.*</h2>") post.delete()
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,770
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/forms.py
from django import forms from django.conf import settings from django.contrib.auth import get_user_model from django.core.validators import MaxLengthValidator from django.utils.functional import cached_property from parler.forms import TranslatableModelForm from taggit_autosuggest.widgets import TagAutoSuggest from .models import BlogCategory, BlogConfig, Post from .settings import PERMALINK_TYPE_CATEGORY, get_setting User = get_user_model() class ConfigFormBase: """Base form class for all models depends on app_config.""" @cached_property def app_config(self): """ Return the currently selected app_config, whether it's an instance attribute or passed in the request """ if getattr(self.instance, "app_config_id", None): return self.instance.app_config elif "app_config" in self.initial: return BlogConfig.objects.get(pk=self.initial["app_config"]) elif self.data.get("app_config", None): return BlogConfig.objects.get(pk=self.data["app_config"]) return None class CategoryAdminForm(ConfigFormBase, TranslatableModelForm): def __init__(self, *args, **kwargs): self.base_fields["meta_description"].validators = [MaxLengthValidator(get_setting("META_DESCRIPTION_LENGTH"))] original_attrs = self.base_fields["meta_description"].widget.attrs if "cols" in original_attrs: del original_attrs["cols"] if "rows" in original_attrs: del original_attrs["rows"] original_attrs["maxlength"] = get_setting("META_DESCRIPTION_LENGTH") self.base_fields["meta_description"].widget = forms.TextInput(original_attrs) super().__init__(*args, **kwargs) if "parent" in self.fields: qs = self.fields["parent"].queryset if self.instance.pk: qs = qs.exclude(pk__in=[self.instance.pk] + [child.pk for child in self.instance.descendants()]) config = None if getattr(self.instance, "app_config_id", None): qs = qs.namespace(self.instance.app_config.namespace) elif "app_config" in self.initial: config = BlogConfig.objects.get(pk=self.initial["app_config"]) elif self.data.get("app_config", None): config = BlogConfig.objects.get(pk=self.data["app_config"]) if config: qs = qs.namespace(config.namespace) self.fields["parent"].queryset = qs class Meta: model = BlogCategory fields = "__all__" class BlogPluginForm(forms.ModelForm): """Base plugin form to inject the list of configured template folders from BLOG_PLUGIN_TEMPLATE_FOLDERS.""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if "template_folder" in self.fields: self.fields["template_folder"].choices = get_setting("PLUGIN_TEMPLATE_FOLDERS") class LatestEntriesForm(BlogPluginForm): """Custom forms for BlogLatestEntriesPlugin to properly load taggit-autosuggest.""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["tags"].widget = TagAutoSuggest("taggit.Tag") class Media: css = {"all": ("{}djangocms_blog/css/{}".format(settings.STATIC_URL, "djangocms_blog_admin.css"),)} class AuthorPostsForm(BlogPluginForm): """Custom form for BlogAuthorPostsPlugin to apply distinct to the list of authors in plugin changeform.""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # apply distinct due to django issue #11707 self.fields["authors"].queryset = User.objects.filter(djangocms_blog_post_author__publish=True).distinct() class PostAdminFormBase(ConfigFormBase, TranslatableModelForm): """ Common methods between the admin and wizard form """ class Meta: model = Post fields = "__all__" @cached_property def available_categories(self): qs = BlogCategory.objects if self.app_config: return qs.namespace(self.app_config.namespace).active_translations() return qs def _post_clean_translation(self, translation): # This is a quickfix for https://github.com/django-parler/django-parler/issues/236 # which needs to be fixed in parler # operating at form level ensure that if the model is validated outside the form # the uniqueness check is not disabled super()._post_clean_translation(translation) self._validate_unique = False class PostAdminForm(PostAdminFormBase): def __init__(self, *args, **kwargs): self.base_fields["meta_description"].validators = [MaxLengthValidator(get_setting("META_DESCRIPTION_LENGTH"))] original_attrs = self.base_fields["meta_description"].widget.attrs if "cols" in original_attrs: del original_attrs["cols"] if "rows" in original_attrs: del original_attrs["rows"] original_attrs["maxlength"] = get_setting("META_DESCRIPTION_LENGTH") self.base_fields["meta_description"].widget = forms.TextInput(original_attrs) self.base_fields["meta_title"].validators = [MaxLengthValidator(get_setting("META_TITLE_LENGTH"))] super().__init__(*args, **kwargs) if "categories" in self.fields: if self.app_config and self.app_config.url_patterns == PERMALINK_TYPE_CATEGORY: self.fields["categories"].required = True self.fields["categories"].queryset = self.available_categories if "app_config" in self.fields: # Don't allow app_configs to be added here. The correct way to add an # apphook-config is to create an apphook on a cms Page. self.fields["app_config"].widget.can_add_related = False if self.app_config: if not self.initial.get("main_image_full", ""): self.initial["main_image_full"] = self.app_config.app_data["config"].get("default_image_full") if not self.initial.get("main_image_thumbnail", ""): self.initial["main_image_thumbnail"] = self.app_config.app_data["config"].get( "default_image_thumbnail" )
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,771
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_models.py
import re from contextlib import contextmanager from copy import deepcopy from datetime import timedelta from unittest import SkipTest from urllib.parse import quote import parler from cms.api import add_plugin from cms.utils.copy_plugins import copy_plugins_to from cms.utils.plugins import downcast_plugins from django.contrib import admin from django.contrib.auth.models import AnonymousUser from django.contrib.messages.middleware import MessageMiddleware from django.contrib.sites.models import Site from django.core.handlers.base import BaseHandler from django.http import QueryDict from django.test import override_settings from django.urls import reverse from django.utils.encoding import force_str from django.utils.html import strip_tags from django.utils.timezone import now from django.utils.translation import get_language, override from easy_thumbnails.files import get_thumbnailer from filer.models import ThumbnailOption from menus.menu_pool import menu_pool from parler.tests.utils import override_parler_settings from parler.utils.conf import add_default_language_settings from parler.utils.context import smart_override from taggit.models import Tag from djangocms_blog.cms_appconfig import BlogConfig, BlogConfigForm from djangocms_blog.forms import CategoryAdminForm, PostAdminForm from djangocms_blog.models import BlogCategory, Post from djangocms_blog.settings import MENU_TYPE_NONE, PERMALINK_TYPE_CATEGORY, PERMALINK_TYPE_FULL_DATE, get_setting from .base import BaseTest from .test_utils.admin import CustomPostAdmin try: from knocker.signals import pause_knocks except ImportError: @contextmanager def pause_knocks(obj): yield class AdminTest(BaseTest): def setUp(self): super().setUp() admin.autodiscover() self.default_thumbnail = ThumbnailOption.objects.create( name="Blog thumbnail", width=120, height=120, crop=True, upscale=True, ) self.default_full = ThumbnailOption.objects.create( name="Blog image", width=800, height=200, crop=True, upscale=True, ) def test_admin_thumbnails(self): self.get_pages() custom_thumbnail = ThumbnailOption.objects.create( name="Custom thumbnail", width=120, height=120, crop=True, upscale=True, ) custom_full = ThumbnailOption.objects.create( name="Custom image", width=800, height=200, crop=True, upscale=True, ) post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") response = post_admin.change_view(request, str(post.pk)) response.render() self.assertRegex(force_str(response.content), r"[^>]*>Custom image") self.assertRegex(force_str(response.content), r"[^>]*>Custom thumbnail") self.assertRegex(force_str(response.content), r"[^>]*>Blog image") self.assertRegex(force_str(response.content), r"[^>]*>Blog thumbnail") post.main_image_full = custom_full post.main_image_thumbnail = custom_thumbnail post.save() response = post_admin.change_view(request, str(post.pk)) response.render() self.assertRegex(force_str(response.content), r"selected[^>]*>Custom image") self.assertRegex(force_str(response.content), r"selected[^>]*>Custom thumbnail") self.app_config_1.app_data.config.default_image_full = self.default_full self.app_config_1.app_data.config.default_image_thumbnail = self.default_thumbnail self.app_config_1.save() post.main_image_full = None post.main_image_thumbnail = None post.save() response = post_admin.change_view(request, str(post.pk)) response.render() self.assertRegex(force_str(response.content), r"selected[^>]*>Blog image") self.assertRegex(force_str(response.content), r"selected[^>]*>Blog thumbnail") def test_admin_category_required(self): self.get_pages() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) BlogCategory.objects.create(name="category 1 - blog 2", app_config=self.app_config_2) post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") response = post_admin.change_view(request, str(post.pk)) self.assertEqual( response.context_data["adminform"].form.fields["categories"].required, self.app_config_1.url_patterns == PERMALINK_TYPE_CATEGORY, ) self.app_config_1.app_data.config.url_patterns = PERMALINK_TYPE_CATEGORY self.app_config_1.save() response = post_admin.change_view(request, str(post.pk)) self.assertEqual( response.context_data["adminform"].form.fields["categories"].required, self.app_config_1.url_patterns == PERMALINK_TYPE_CATEGORY, ) self.app_config_1.app_data.config.url_patterns = PERMALINK_TYPE_FULL_DATE self.app_config_1.save() def test_admin_post_views(self): self.get_pages() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") # Add view only contains the apphook selection widget response = post_admin.add_view(request) self.assertNotContains(response, '<input id="id_slug" maxlength="752" name="slug" type="text"') self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk) # Changeview is 'normal' response = post_admin.change_view(request, str(post.pk)) response.render() try: self.assertRegex(force_str(response.content), r'name="slug"[^>]*value="first-post"') except AssertionError: self.assertRegex(force_str(response.content), r'value="first-post"[^>]*name="slug"') try: self.assertRegex(force_str(response.content), r'id="id_meta_description"[^>]*maxlength="320"') except AssertionError: self.assertRegex(force_str(response.content), r'maxlength="320"[^>]*id="id_meta_description"') try: self.assertRegex( force_str(response.content), r'selected[^>]*value="%s">Blog / sample_app</option>' % self.app_config_1.pk, ) except AssertionError: self.assertRegex( force_str(response.content), r'value="%s"[^>]*selected[^>]*>Blog / sample_app</option>' % self.app_config_1.pk, ) # Test for publish view post.publish = False post.save() response = post_admin.publish_post(request, str(post.pk)) # Redirects to current post self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], post.get_absolute_url()) post = self.reload_model(post) # post is publshed self.assertTrue(post.publish) # Non-existing post is redirected to posts list response = post_admin.publish_post(request, "1000000") self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], reverse("djangocms_blog:posts-latest")) # unless a referer is set request.META["HTTP_REFERER"] = "/" # reset headers cached property del request.headers response = post_admin.publish_post(request, "1000000") self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], "/") def test_admin_post_delete(self): self.get_pages() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") post_admin.delete_model(request, post) def test_admin_post_delete_queryset(self): self.get_pages() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) post_admin.delete_queryset(request, post_admin.get_queryset(request)) def test_admin_changelist_view(self): self.get_pages() posts = self.get_posts() post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) # Normal changelist, all existing posts response = post_admin.changelist_view(request) self.assertEqual(response.context_data["cl"].queryset.count(), len(posts)) self.assertTrue(posts[0] in response.context_data["cl"].queryset.all()) # Site 2 is added to first post, but no changelist filter, no changes posts[0].sites.add(self.site_2) response = post_admin.changelist_view(request) self.assertTrue(posts[0] in response.context_data["cl"].queryset.all()) # Filtering on site, first post not shown request = self.get_page_request("/", self.user, r"/en/blog/?sites=1", edit=False) response = post_admin.changelist_view(request) self.assertEqual(response.context_data["cl"].queryset.count(), len(posts) - 1) self.assertTrue(posts[0] not in response.context_data["cl"].queryset.all()) # Removing site filtering, first post appears again request = self.get_page_request("/", self.user, r"/en/blog/?", edit=False) response = post_admin.changelist_view(request) self.assertEqual(response.context_data["cl"].queryset.count(), len(posts)) self.assertTrue(posts[0] in response.context_data["cl"].queryset.all()) # Filtering on the apphook config and site request = self.get_page_request( "/", self.user, r"/en/blog/?app_config__id__exact=%s&sites=1" % self.app_config_1.pk, edit=False ) response = post_admin.changelist_view(request) # First and last post in the list are now in the queryset self.assertEqual(response.context_data["cl"].queryset.count(), len(posts) - 2) self.assertTrue(posts[0] not in response.context_data["cl"].queryset.all()) self.assertTrue(posts[-1] not in response.context_data["cl"].queryset.all()) # Publishing one post, two published in total posts[1].publish = True posts[1].save() published = Post.objects.published(current_site=False) request = self.get_page_request("/", self.user, r"/en/blog/?publish__exact=1", edit=False) response = post_admin.changelist_view(request) # The admin queryset and the model queryset are the same self.assertEqual(response.context_data["cl"].queryset.count(), published.count()) # Published post is in the changelist queryset self.assertTrue(posts[1] in response.context_data["cl"].queryset.all()) def test_admin_blogconfig_views(self): post_admin = admin.site._registry[BlogConfig] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) # Add view only has an empty form - no type response = post_admin.add_view(request) response.render() self.assertNotContains(response, "djangocms_blog.cms_appconfig.BlogConfig") try: self.assertRegex(force_str(response.content), r'maxlength="100"[^>]*id="id_namespace"') except AssertionError: self.assertRegex(force_str(response.content), r'id="id_namespace"[^>]*maxlength="100"') # Changeview is 'normal', with a few preselected items response = post_admin.change_view(request, str(self.app_config_1.pk)) self.assertContains(response, "djangocms_blog.cms_appconfig.BlogConfig") try: self.assertRegex(force_str(response.content), r'selected[^>]*value="Article">Article') except AssertionError: self.assertRegex(force_str(response.content), r'value="Article"[^>]*selected[^>]*>Article') # check that all the form fields are visible in the admin for fieldname in BlogConfigForm.base_fields: self.assertContains(response, 'id="id_config-%s"' % fieldname) try: self.assertRegex(force_str(response.content), r'maxlength="200"[^>]*id="id_config-og_app_id"') except AssertionError: self.assertRegex(force_str(response.content), r'id="id_config-og_app_id"[^>]*maxlength="200"') self.assertContains(response, "sample_app") def test_admin_category_views(self): category_admin = admin.site._registry[BlogCategory] request = self.get_page_request("/", self.user, r"/en/blog/", edit=False) BlogCategory.objects.create(name="category 1 - blog 2", app_config=self.app_config_2) # Add view only has an empty form - no type response = category_admin.add_view(request) self.assertNotContains(response, 'value="category 1"') self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk) # Add view select categories on the given appconfig, even when reloading the form request.POST = QueryDict("app_config=%s" % self.app_config_1.pk) request.method = "POST" response = category_admin.add_view(request) self.assertEqual( list(response.context_data["adminform"].form.fields["parent"].queryset), list(BlogCategory.objects.filter(app_config=self.app_config_1)), ) request.GET = QueryDict("app_config=%s" % self.app_config_1.pk) request.method = "GET" response = category_admin.add_view(request) self.assertEqual( list(response.context_data["adminform"].form.fields["parent"].queryset), list(BlogCategory.objects.filter(app_config=self.app_config_1)), ) # Changeview is 'normal', with a few preselected items request.GET = QueryDict() response = category_admin.change_view(request, str(self.category_1.pk)) response.render() try: self.assertRegex(force_str(response.content), r'id="id_name"[^>]*value="category 1"') except AssertionError: self.assertRegex(force_str(response.content), r'value="category 1"[^>]*id="id_name"') try: self.assertRegex(force_str(response.content), r'id="id_meta_description"[^>]*maxlength="320"') except AssertionError: self.assertRegex(force_str(response.content), r'maxlength="320"[^>]*id="id_meta_description"') try: self.assertRegex( force_str(response.content), r'selected[^>]*value="%s">Blog / sample_app</option>' % self.app_config_1.pk, ) except AssertionError: self.assertRegex( force_str(response.content), r'value="%s"[^>]*selected[^>]*>Blog / sample_app</option>' % self.app_config_1.pk, ) def test_form(self): posts = self.get_posts() with override_settings(BLOG_META_DESCRIPTION_LENGTH=20, BLOG_META_TITLE_LENGTH=20): form = PostAdminForm(data={"meta_description": "major text over 20 characters long"}, instance=posts[0]) self.assertFalse(form.is_valid()) form = PostAdminForm(data={"meta_title": "major text over 20 characters long"}, instance=posts[0]) self.assertFalse(form.is_valid()) form = CategoryAdminForm( data={"meta_description": "major text over 20 characters long"}, instance=self.category_1 ) self.assertFalse(form.is_valid()) form = PostAdminForm(data={"meta_description": "mini text"}, instance=posts[0]) self.assertFalse(form.is_valid()) form = PostAdminForm(data={"meta_title": "mini text"}, instance=posts[0]) self.assertFalse(form.is_valid()) form = CategoryAdminForm(data={"meta_description": "mini text"}, instance=self.category_1) self.assertFalse(form.is_valid()) def test_admin_category_parents(self): category1 = BlogCategory.objects.create(name="tree category 1", app_config=self.app_config_1) category2 = BlogCategory.objects.create(name="tree category 2", parent=category1, app_config=self.app_config_1) category3 = BlogCategory.objects.create(name="tree category 3", parent=category2, app_config=self.app_config_1) BlogCategory.objects.create(name="tree category 4", parent=category3, app_config=self.app_config_1) BlogCategory.objects.create(name="category different branch", app_config=self.app_config_2) post_admin = admin.site._registry[BlogCategory] request = self.get_page_request("/", self.user, r"/en/blog/?app_config=%s" % self.app_config_1.pk, edit=False) # Add view shows all the exising categories response = post_admin.add_view(request) self.assertTrue( response.context_data["adminform"].form.fields["parent"].queryset, BlogCategory.objects.filter(app_config=self.app_config_1), ) # Changeview hides the children of the current category response = post_admin.change_view(request, str(category2.pk)) self.assertTrue( response.context_data["adminform"].form.fields["parent"].queryset, BlogCategory.objects.filter(app_config=self.app_config_1, parent__isnull=True), ) # Test second apphook categories request = self.get_page_request("/", self.user, r"/en/blog/?app_config=%s" % self.app_config_2.pk, edit=False) response = post_admin.add_view(request) self.assertTrue( response.context_data["adminform"].form.fields["parent"].queryset, BlogCategory.objects.filter(app_config=self.app_config_2), ) def test_admin_fieldsets(self): handler = BaseHandler() post_admin = admin.site._registry[Post] request = self.get_page_request( "/", self.user_staff, r"/en/blog/?app_config=%s" % self.app_config_1.pk, edit=False ) # Use placeholder self.app_config_1.app_data.config.use_placeholder = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("post_text" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_placeholder = False self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertTrue("post_text" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_placeholder = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("post_text" in fsets[0][1]["fields"]) # Use related posts self.app_config_1.app_data.config.use_related = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("related" in fsets[1][1]["fields"][0]) Post.objects.language("en").create(title="post x", app_config=self.app_config_1) fsets = post_admin.get_fieldsets(request) self.assertTrue("related" in fsets[1][1]["fields"][0]) self.app_config_1.app_data.config.use_related = False self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("related" in fsets[1][1]["fields"][0]) self.app_config_1.app_data.config.use_related = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertTrue("related" in fsets[1][1]["fields"][0]) # Use abstract self.app_config_1.app_data.config.use_abstract = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertTrue("abstract" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_abstract = False self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("abstract" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_abstract = True self.app_config_1.app_data.config.default_image_full = self.default_full self.app_config_1.app_data.config.default_image_thumbnail = self.default_thumbnail self.app_config_1.save() with self.settings(BLOG_MULTISITE=True): fsets = post_admin.get_fieldsets(request) self.assertTrue("sites" in fsets[1][1]["fields"][0]) with self.settings(BLOG_MULTISITE=False): fsets = post_admin.get_fieldsets(request) self.assertFalse("sites" in fsets[1][1]["fields"][0]) request = self.get_page_request("/", self.user, r"/en/blog/?app_config=%s" % self.app_config_1.pk, edit=False) fsets = post_admin.get_fieldsets(request) self.assertTrue("author" in fsets[1][1]["fields"][0]) with self.login_user_context(self.user): request = self.get_request( "/", "en", user=self.user, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk ) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.add_view(request) self.assertTrue( response.context_data["adminform"].form.fields["categories"].queryset, BlogCategory.objects.filter(app_config=self.app_config_1), ) response.render() self.assertContains(response, 'id="id_sites"') self.assertRegex(force_str(response.content), r"selected[^>]*>Blog image") self.assertRegex(force_str(response.content), r"selected[^>]*>Blog thumbnail") # Add view select categories on the given appconfig, even when reloading the form request.POST = QueryDict("app_config=%s" % self.app_config_1.pk) request.method = "POST" response = post_admin.add_view(request) self.assertTrue( response.context_data["adminform"].form.fields["categories"].queryset, BlogCategory.objects.filter(app_config=self.app_config_1), ) request.GET = QueryDict("app_config=%s" % self.app_config_1.pk) request.method = "GET" response = post_admin.add_view(request) self.assertTrue( response.context_data["adminform"].form.fields["categories"].queryset, BlogCategory.objects.filter(app_config=self.app_config_1), ) self.user.sites.add(self.site_1) with self.login_user_context(self.user): request = self.get_request( "/", "en", user=self.user, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk ) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] post_admin._sites = None response = post_admin.add_view(request) response.render() self.assertNotContains(response, 'id="id_sites" name="sites"') post_admin._sites = None self.user.sites.clear() def test_custom_admin_fieldsets(self): post_admin = CustomPostAdmin(Post, admin_site=admin.site) request = self.get_page_request( "/", self.user_staff, r"/en/blog/?app_config=%s" % self.app_config_1.pk, edit=False ) # Use placeholder self.app_config_1.app_data.config.use_placeholder = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("post_text" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_placeholder = False self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertTrue("post_text" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_placeholder = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("post_text" in fsets[0][1]["fields"]) # Related field is always hidden due to the value in CustomPostAdmin._fieldset_extra_fields_position self.app_config_1.app_data.config.use_related = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("related" in fsets[1][1]["fields"][0]) Post.objects.language("en").create(title="post x", app_config=self.app_config_1) fsets = post_admin.get_fieldsets(request) self.assertFalse("related" in fsets[1][1]["fields"][0]) self.app_config_1.app_data.config.use_related = False self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("related" in fsets[1][1]["fields"][0]) self.app_config_1.app_data.config.use_related = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("related" in fsets[1][1]["fields"][0]) # Use abstract self.app_config_1.app_data.config.use_abstract = True self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertTrue("abstract" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_abstract = False self.app_config_1.save() fsets = post_admin.get_fieldsets(request) self.assertFalse("abstract" in fsets[0][1]["fields"]) self.app_config_1.app_data.config.use_abstract = True self.app_config_1.app_data.config.default_image_full = self.default_full self.app_config_1.app_data.config.default_image_thumbnail = self.default_thumbnail self.app_config_1.save() with self.settings(BLOG_MULTISITE=True): fsets = post_admin.get_fieldsets(request) self.assertTrue("sites" in fsets[1][1]["fields"][0]) with self.settings(BLOG_MULTISITE=False): fsets = post_admin.get_fieldsets(request) self.assertFalse("sites" in fsets[1][1]["fields"][0]) request = self.get_page_request("/", self.user, r"/en/blog/?app_config=%s" % self.app_config_1.pk, edit=False) fsets = post_admin.get_fieldsets(request) self.assertTrue("author" in fsets[1][1]["fields"]) def test_admin_queryset(self): posts = self.get_posts() posts[0].sites.add(self.site_1) posts[1].sites.add(self.site_2) request = self.get_request("/", "en", user=self.user, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk) post_admin = admin.site._registry[Post] post_admin._sites = None qs = post_admin.get_queryset(request) self.assertEqual(qs.count(), 4) self.user.sites.add(self.site_2) request = self.get_request("/", "en", user=self.user, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk) post_admin = admin.site._registry[Post] post_admin._sites = None qs = post_admin.get_queryset(request) self.assertEqual(qs.count(), 1) self.assertEqual(qs[0], posts[1]) self.user.sites.clear() def test_admin_auto_author(self): pages = self.get_pages() data = deepcopy(self._post_data[0]["en"]) handler = BaseHandler() with self.login_user_context(self.user): self.app_config_1.app_data.config.set_author = True self.app_config_1.save() data["date_published_0"] = now().strftime("%Y-%m-%d") data["date_published_1"] = now().strftime("%H:%M:%S") data["categories"] = self.category_1.pk data["app_config"] = self.app_config_1.pk request = self.post_request( pages[0], "en", user=self.user, data=data, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk ) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.add_view(request) self.assertEqual(response.status_code, 302) self.assertEqual(Post.objects.count(), 1) self.assertEqual(Post.objects.get(translations__slug="first-post").author_id, request.user.pk) self.app_config_1.app_data.config.set_author = False self.app_config_1.save() data = deepcopy(self._post_data[1]["en"]) data["date_published_0"] = now().strftime("%Y-%m-%d") data["date_published_1"] = now().strftime("%H:%M:%S") data["categories"] = self.category_1.pk data["app_config"] = self.app_config_1.pk request = self.post_request( pages[0], "en", user=self.user, data=data, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk ) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.add_view(request) self.assertEqual(response.status_code, 302) self.assertEqual(Post.objects.count(), 2) self.assertEqual(Post.objects.get(translations__slug="second-post").author_id, None) with self.settings(BLOG_AUTHOR_DEFAULT="staff"): self.app_config_1.app_data.config.set_author = True self.app_config_1.save() data = deepcopy(self._post_data[2]["en"]) data["date_published_0"] = now().strftime("%Y-%m-%d") data["date_published_1"] = now().strftime("%H:%M:%S") data["categories"] = self.category_1.pk data["app_config"] = self.app_config_1.pk request = self.post_request( pages[0], "en", user=self.user, data=data, path=r"/en/blog/?app_config=%s" % self.app_config_1.pk ) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.add_view(request) self.assertEqual(response.status_code, 302) self.assertEqual(Post.objects.count(), 3) self.assertEqual(Post.objects.get(translations__slug="third-post").author.username, "staff") def test_admin_fieldsets_filter(self): post_admin = admin.site._registry[Post] request = self.get_page_request("/", self.user_normal, r"/en/blog/?app_config=%s" % self.app_config_1.pk) post_admin._sites = None fsets = post_admin.get_fieldsets(request) self.assertFalse("author" in fsets[1][1]["fields"][0]) self.assertTrue("sites" in fsets[1][1]["fields"][0]) post_admin._sites = None def filter_function(fs, request, obj=None): if request.user == self.user_normal: fs[1][1]["fields"][0].append("author") return fs self.user_normal.sites.add(self.site_1) request = self.get_page_request("/", self.user_normal, r"/en/blog/?app_config=%s" % self.app_config_1.pk) post_admin._sites = None with self.settings(BLOG_ADMIN_POST_FIELDSET_FILTER=filter_function): fsets = post_admin.get_fieldsets(request) self.assertTrue("author" in fsets[1][1]["fields"][0]) self.assertFalse("sites" in fsets[1][1]["fields"][0]) post_admin._sites = None self.user_normal.sites.clear() def test_admin_post_text(self): pages = self.get_pages() post = self._get_post(self._post_data[0]["en"]) handler = BaseHandler() with pause_knocks(post): with self.login_user_context(self.user): with self.settings(BLOG_USE_PLACEHOLDER=False): data = {"post_text": "ehi text", "title": "some title"} request = self.post_request( pages[0], "en", user=self.user, data=data, path="/en/?edit_fields=post_text" ) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.edit_field(request, post.pk, "en") self.assertEqual(response.status_code, 200) modified_post = Post.objects.language("en").get(pk=post.pk) self.assertEqual(modified_post.safe_translation_getter("post_text"), data["post_text"]) def test_admin_publish_post_view(self): self.get_pages() post = self._get_post(self._post_data[0]["en"]) with pause_knocks(post): post.publish = False post.save() self.client.force_login(self.user) response = self.client.post(reverse("admin:djangocms_blog_publish_article", args=(post.pk,))) post.refresh_from_db() self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], post.get_absolute_url()) self.assertTrue(post.publish) def test_admin_site(self): pages = self.get_pages() post = self._get_post(self._post_data[0]["en"]) handler = BaseHandler() # no restrictions, sites are assigned with self.login_user_context(self.user): data = { "sites": [self.site_1.pk, self.site_2.pk], "title": "some title", "app_config": self.app_config_1.pk, } request = self.post_request(pages[0], "en", user=self.user, data=data, path="/en/") self.assertEqual(post.sites.count(), 0) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.change_view(request, str(post.pk)) self.assertEqual(response.status_code, 302) post = self.reload_model(post) self.assertEqual(post.sites.count(), 2) post.sites.clear() post = self.reload_model(post) # user only allowed on 2 sites, can add both self.user.sites.add(self.site_2) self.user.sites.add(self.site_3) post.sites.add(self.site_1) post.sites.add(self.site_2) self.user = self.reload_model(self.user) with self.login_user_context(self.user): data = { "sites": [self.site_2.pk, self.site_3.pk], "title": "some title", "app_config": self.app_config_1.pk, } request = self.post_request(pages[0], "en", user=self.user, data=data, path="/en/") self.assertEqual(post.sites.count(), 2) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] post_admin._sites = None response = post_admin.change_view(request, str(post.pk)) self.assertEqual(response.status_code, 302) post = self.reload_model(post) self.assertEqual(post.sites.count(), 3) self.user.sites.clear() post.sites.clear() # user only allowed on 2 sites, can remove one of his sites post = self.reload_model(post) post.sites.add(self.site_1) post.sites.add(self.site_2) post.sites.add(self.site_3) self.user.sites.add(self.site_2) self.user.sites.add(self.site_3) with self.login_user_context(self.user): data = {"sites": [self.site_3.pk], "title": "some title", "app_config": self.app_config_1.pk} request = self.post_request(pages[0], "en", user=self.user, data=data, path="/en/") self.assertEqual(post.sites.count(), 3) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] post_admin._sites = None response = post_admin.change_view(request, str(post.pk)) self.assertEqual(response.status_code, 302) post = self.reload_model(post) self.assertEqual(post.sites.count(), 2) self.user.sites.clear() post.sites.clear() # user only allowed on 2 sites, if given sites is empty, the site with no permission on # is kept post = self.reload_model(post) post.sites.add(self.site_1) post.sites.add(self.site_3) self.user.sites.add(self.site_2) self.user.sites.add(self.site_3) with self.login_user_context(self.user): data = {"sites": [], "title": "some title", "app_config": self.app_config_1.pk} request = self.post_request(pages[0], "en", user=self.user, data=data, path="/en/") self.assertEqual(post.sites.count(), 2) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) post_admin = admin.site._registry[Post] post_admin._sites = None response = post_admin.change_view(request, str(post.pk)) self.assertEqual(response.status_code, 302) post = self.reload_model(post) self.assertEqual(post.sites.count(), 1) self.user.sites.clear() post.sites.clear() self.reload_model(post) def test_admin_clear_menu(self): """ Tests that after changing apphook config menu structure the menu content is different: new value is taken immediately into account """ handler = BaseHandler() self._reload_menus() pages = self.get_pages() post = self._get_post(self._post_data[0]["en"]) request = self.get_page_request(None, self.user, r"/en/page-two/") first_nodes = self.get_nodes(menu_pool, request) self._reset_menus() with pause_knocks(post): with self.login_user_context(self.user): data = dict(namespace="sample_app", app_title="app1", object_name="Blog") data["config-menu_structure"] = MENU_TYPE_NONE data["config-sitemap_changefreq"] = "weekly" data["config-sitemap_priority"] = "0.5" request = self.post_request(pages[0], "en", user=self.user, data=data) msg_mid = MessageMiddleware(handler) msg_mid.process_request(request) config_admin = admin.site._registry[BlogConfig] config_admin.change_view(request, str(self.app_config_1.pk)) second_nodes = self.get_nodes(menu_pool, request) self.assertNotEqual(len(first_nodes), len(second_nodes)) class ModelsTest(BaseTest): def test_category_attributes(self): posts = self.get_posts() posts[0].publish = True posts[0].save() posts[1].publish = True posts[1].save() posts[1].sites.add(self.site_2) new_category = BlogCategory.objects.create(name="category 2", app_config=self.app_config_1) posts[1].categories.add(new_category) with self.settings(SITE_ID=2): self.assertEqual(new_category.count, 1) self.assertEqual(self.category_1.count, 2) self.assertEqual(new_category.count_all_sites, 1) self.assertEqual(self.category_1.count_all_sites, 2) # needed to clear cached properties new_category = self.reload_model(new_category) self.category_1 = self.reload_model(self.category_1) with self.settings(SITE_ID=1): self.assertEqual(new_category.count, 0) self.assertEqual(self.category_1.count, 1) self.assertEqual(new_category.count_all_sites, 1) self.assertEqual(self.category_1.count_all_sites, 2) def test_slug(self): post = Post.objects.language("en").create(title="I am a title") self.assertEqual(post.slug, "i-am-a-title") # Test unicode chars in slugs post = Post.objects.language("fr").create(title="Accentué") self.assertEqual(post.slug, "accentué") def test_model_attributes(self): self.get_pages() featured_date = now() + timedelta(days=40) post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") post.main_image = self.create_filer_image_object() post.publish = True post.save() post.set_current_language("en") self.assertEqual(post.date, post.date_published) post.date_featured = featured_date post.save() self.assertEqual(post.date, featured_date) meta_en = post.as_meta() self.assertEqual(meta_en.og_type, get_setting("FB_TYPE")) self.assertEqual(meta_en.title, post.title) self.assertTrue(meta_en.url.endswith(post.get_absolute_url())) self.assertEqual(meta_en.description, post.meta_description) self.assertEqual(meta_en.keywords, post.meta_keywords.split(",")) self.assertEqual(meta_en.published_time, post.date_published) self.assertEqual(meta_en.locale, "en") self.assertEqual(meta_en.twitter_site, "") self.assertEqual(meta_en.twitter_author, "") self.assertEqual(meta_en.twitter_type, "summary") self.assertEqual(meta_en.schemaorg_type, "Blog") self.assertEqual(meta_en.schemaorg_title, post.title) self.assertEqual(meta_en.schemaorg_description, post.meta_description) self.assertEqual(meta_en.og_type, "Article") self.assertEqual(meta_en.image_width, post.main_image.width) self.assertEqual(meta_en.image_height, post.main_image.height) self.assertEqual(meta_en.facebook_app_id, None) post.set_current_language("it") meta_it = post.as_meta() self.assertEqual(meta_it.title, post.title) self.assertTrue(meta_it.url.endswith(post.get_absolute_url())) self.assertNotEqual(meta_it.title, meta_en.title) self.assertEqual(meta_it.description, post.meta_description) category = post.categories.first() meta_cat = category.as_meta() self.assertEqual(meta_cat.og_type, get_setting("FB_TYPE")) self.assertEqual(meta_cat.title, category.name) self.assertEqual(meta_cat.description, category.meta_description) self.assertEqual(meta_cat.locale, "en") self.assertEqual(meta_cat.twitter_site, "") self.assertEqual(meta_cat.twitter_author, "") self.assertEqual(meta_cat.twitter_type, "summary") self.assertEqual(meta_cat.schemaorg_type, "Blog") self.assertEqual(meta_cat.og_type, "Article") self.assertEqual(meta_cat.facebook_app_id, None) self.assertTrue(meta_cat.url.endswith(category.get_absolute_url())) with override("en"): post.set_current_language(get_language()) kwargs = { "year": post.date_published.year, "month": "%02d" % post.date_published.month, "day": "%02d" % post.date_published.day, "slug": post.safe_translation_getter("slug", any_language=get_language()), } url_en = reverse( "%s:post-detail" % self.app_config_1.namespace, kwargs=kwargs, current_app=self.app_config_1.namespace ) self.assertEqual(url_en, post.get_absolute_url()) with override("it"): post.set_current_language(get_language()) kwargs = { "year": post.date_published.year, "month": "%02d" % post.date_published.month, "day": "%02d" % post.date_published.day, "slug": post.safe_translation_getter("slug", any_language=get_language()), } url_it = reverse( "%s:post-detail" % self.app_config_1.namespace, kwargs=kwargs, current_app=self.app_config_1.namespace ) self.assertEqual(url_it, post.get_absolute_url()) self.assertNotEqual(url_it, url_en) self.assertEqual(post.get_full_url(), "http://example.com%s" % url_it) self.assertEqual(post.get_image_full_url(), "http://example.com%s" % post.main_image.url) self.assertEqual(post.thumbnail_options(), get_setting("IMAGE_THUMBNAIL_SIZE")) self.assertEqual(post.full_image_options(), get_setting("IMAGE_FULL_SIZE")) post.main_image_thumbnail = self.thumb_1 post.main_image_full = self.thumb_2 self.assertEqual( post.thumbnail_options(), {"size": (100, 100), "width": 100, "height": 100, "crop": True, "upscale": False} ) self.assertEqual( post.full_image_options(), {"size": (200, 200), "width": 200, "height": 200, "crop": False, "upscale": False}, ) post.set_current_language("en") post.meta_title = "meta title" self.assertEqual(post.get_title(), "meta title") # Assess is_published property post.publish = False post.save() self.assertFalse(post.is_published) post.publish = True post.date_published = now() + timedelta(days=1) post.date_published_end = None post.save() self.assertFalse(post.is_published) post.publish = True post.date_published = now() - timedelta(days=1) post.date_published_end = now() - timedelta(minutes=1) post.save() self.assertFalse(post.is_published) post.publish = True post.date_published = now() - timedelta(days=1) post.date_published_end = None post.save() self.assertTrue(post.is_published) post.publish = True post.date_published = now() - timedelta(days=1) post.date_published_end = now() + timedelta(minutes=1) post.save() self.assertTrue(post.is_published) post.publish = False post.date_published = now() - timedelta(days=1) post.date_published_end = None post.save() self.assertFalse(post.is_published) post.publish = False post.date_published = now() - timedelta(days=1) post.date_published_end = now() + timedelta(minutes=1) post.save() self.assertFalse(post.is_published) def test_model_meta_image_setting(self): post = self._get_post(self._post_data[0]["en"]) post.main_image = self.create_filer_image_object() post.save() post.set_current_language("en") meta_en = post.as_meta() self.assertEqual(meta_en.image, post.build_absolute_uri(post.main_image.url)) self.assertEqual(meta_en.image_width, post.main_image.width) self.assertEqual(meta_en.image_height, post.main_image.height) with override_settings(BLOG_META_IMAGE_SIZE={"size": (1200, 630), "crop": True, "upscale": False}): meta_en = post.as_meta() self.assertEqual( meta_en.image, post.build_absolute_uri( get_thumbnailer(post.main_image).get_thumbnail(get_setting("META_IMAGE_SIZE")).url ), ) self.assertEqual( meta_en.image_width, get_thumbnailer(post.main_image).get_thumbnail(get_setting("META_IMAGE_SIZE")).width, ) self.assertEqual( meta_en.image_height, get_thumbnailer(post.main_image).get_thumbnail(get_setting("META_IMAGE_SIZE")).height, ) def test_urls(self): self.get_pages() post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") # default self.assertTrue(re.match(r".*\d{4}/\d{2}/\d{2}/%s/$" % post.slug, post.get_absolute_url())) # full date self.app_config_1.app_data.config.url_patterns = "full_date" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*\d{4}/\d{2}/\d{2}/%s/$" % post.slug, post.get_absolute_url())) # short date self.app_config_1.app_data.config.url_patterns = "short_date" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*\d{4}/\d{2}/%s/$" % post.slug, post.get_absolute_url())) # category self.app_config_1.app_data.config.url_patterns = "category" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*/\w[-\w]*/%s/$" % post.slug, post.get_absolute_url())) self.assertTrue( re.match(r".*{}/{}/$".format(post.categories.first().slug, post.slug), post.get_absolute_url()) ) # slug only self.app_config_1.app_data.config.url_patterns = "category" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*/%s/$" % post.slug, post.get_absolute_url())) # Unicode chars in slugs post = Post.objects.language("fr").create(title="Accentué") category = BlogCategory.objects.create(name="Catégorie 2", app_config=self.app_config_1) category.set_current_language("fr", initialize=True) post.categories.add(category) # full date self.app_config_1.app_data.config.url_patterns = "full_date" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*\d{4}/\d{2}/\d{2}/%s/$" % quote(post.slug), post.get_absolute_url())) # short date self.app_config_1.app_data.config.url_patterns = "short_date" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*\d{4}/\d{2}/%s/$" % quote(post.slug), post.get_absolute_url())) # category self.app_config_1.app_data.config.url_patterns = "category" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue( re.match( r".*{}/{}/$".format(quote(post.categories.first().slug), quote(post.slug)), post.get_absolute_url(), ) ) # slug only self.app_config_1.app_data.config.url_patterns = "category" self.app_config_1.save() post.app_config = self.app_config_1 self.assertTrue(re.match(r".*/%s/$" % quote(post.slug), post.get_absolute_url())) def test_url_language(self): self.get_pages() post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") with override("it"): self.assertEqual(post.get_current_language(), "en") self.assertEqual(post.get_absolute_url(), post.get_absolute_url("it")) post.set_current_language("it") with override("en"): self.assertEqual(post.get_current_language(), "it") self.assertEqual(post.get_absolute_url(), post.get_absolute_url("en")) def test_url_language_use_fallback(self): self.get_pages() post = self._get_post(self._post_data[0]["en"]) PARLER_FALLBACK = { # noqa: N806 1: ( {"code": "en"}, {"code": "it"}, ), "default": {"fallbacks": ["fr", "en"], "hide_untranslated": False}, } PARLER_FALLBACK = add_default_language_settings(PARLER_FALLBACK) # noqa: N806 with override_parler_settings(PARLER_LANGUAGES=PARLER_FALLBACK): with override("it"): post.set_current_language("it") self.assertEqual(post.get_absolute_url(), post.get_absolute_url("it")) with override_settings(BLOG_USE_FALLBACK_LANGUAGE_IN_URL=True): with override("it"): post.set_current_language("it") self.assertEqual(post.get_absolute_url(), post.get_absolute_url("en")) def test_manager(self): self.get_pages() post1 = self._get_post(self._post_data[0]["en"]) post2 = self._get_post(self._post_data[1]["en"]) # default queryset, published and unpublished posts months = Post.objects.get_months() for data in months: self.assertEqual(data["date"].date(), now().replace(year=now().year, month=now().month, day=1).date()) self.assertEqual(data["count"], 2) # custom queryset, only published post1.publish = True post1.save() months = Post.objects.get_months(Post.objects.published()) for data in months: self.assertEqual(data["date"].date(), now().replace(year=now().year, month=now().month, day=1).date()) self.assertEqual(data["count"], 1) # Move post to different site to filter it out post2.sites.add(self.site_2) months = Post.objects.get_months() for data in months: self.assertEqual(data["date"].date(), now().replace(year=now().year, month=now().month, day=1).date()) self.assertEqual(data["count"], 1) months = Post.objects.get_months(current_site=False) for data in months: self.assertEqual(data["date"].date(), now().replace(year=now().year, month=now().month, day=1).date()) self.assertEqual(data["count"], 2) post2.sites.clear() self.assertEqual(len(Post.objects.available()), 1) # If post is published but publishing date is in the future post2.date_published = now().replace(year=now().year + 1, month=now().month, day=1) post2.publish = True post2.save() self.assertEqual(len(Post.objects.available()), 2) self.assertEqual(len(Post.objects.published()), 1) self.assertEqual(len(Post.objects.published_future()), 2) self.assertEqual(len(Post.objects.archived()), 0) self.assertEqual(len(Post.objects.archived(current_site=False)), 0) # If post is published but end publishing date is in the past post2.date_published = now().replace(year=now().year - 2, month=now().month, day=1) post2.date_published_end = now().replace(year=now().year - 1, month=now().month, day=1) post2.save() self.assertEqual(len(Post.objects.available()), 2) self.assertEqual(len(Post.objects.published()), 1) self.assertEqual(len(Post.objects.archived()), 1) self.assertEqual(len(Post.objects.archived(current_site=False)), 1) # Move post to different site to filter it out post2.sites.add(self.site_2) self.assertEqual(len(Post.objects.archived()), 0) self.assertEqual(len(Post.objects.archived(current_site=False)), 1) self.assertEqual(len(Post.objects.available()), 1) self.assertEqual(len(Post.objects.available(current_site=False)), 2) self.assertEqual(len(Post.objects.published()), 1) # publish post post2.date_published = now() - timedelta(days=1) post2.date_published_end = now() + timedelta(days=10) post2.save() self.assertEqual(len(Post.objects.archived()), 0) self.assertEqual(len(Post.objects.archived(current_site=False)), 0) self.assertEqual(len(Post.objects.available()), 1) self.assertEqual(len(Post.objects.available(current_site=False)), 2) self.assertEqual(len(Post.objects.published()), 1) self.assertEqual(len(Post.objects.published(current_site=False)), 2) # counting with language fallback enabled self._get_post(self._post_data[0]["it"], post1, "it") self.assertEqual(len(Post.objects.filter_by_language("it")), 1) self.assertEqual(len(Post.objects.filter_by_language("it", current_site=False)), 2) post2.sites.clear() # No fallback parler.appsettings.PARLER_LANGUAGES["default"]["hide_untranslated"] = True for index, _lang in enumerate(parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk]): parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk][index]["hide_untranslated"] = True self.assertEqual(len(Post.objects.filter_by_language("it")), 1) parler.appsettings.PARLER_LANGUAGES["default"]["hide_untranslated"] = False for index, _lang in enumerate(parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk]): parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk][index]["hide_untranslated"] = False def test_tag_cloud(self): post1 = self._get_post(self._post_data[0]["en"]) post2 = self._get_post(self._post_data[1]["en"]) post1.tags.add("tag 1", "tag 2", "tag 3", "tag 4") post1.save() post2.tags.add("tag 6", "tag 2", "tag 5", "tag 8") post2.save() self.assertEqual(len(Post.objects.tag_cloud()), 0) tags = [] for tag in Tag.objects.all(): if tag.slug == "tag-2": tag.count = 2 else: tag.count = 1 tags.append(tag) self.assertEqual(Post.objects.tag_cloud(published=True), []) self.assertEqual(set(Post.objects.tag_cloud(published=False)), set(tags)) tags_1 = [] for tag in Tag.objects.all(): if tag.slug == "tag-2": tag.count = 2 tags_1.append(tag) elif tag.slug in ("tag-1", "tag-3", "tag-4"): tag.count = 1 tags_1.append(tag) post1.publish = True post1.save() self.assertEqual(set(Post.objects.tag_cloud()), set(tags_1)) self.assertEqual(set(Post.objects.tag_cloud(published=False)), set(tags)) tags1 = set(Post.objects.tag_list(Post)) tags2 = set(Tag.objects.all()) self.assertEqual(tags1, tags2) self.assertEqual( list(Post.objects.tagged(queryset=Post.objects.filter(pk=post1.pk)).order_by("pk").values_list("pk")), list(Post.objects.filter(pk__in=(post1.pk, post2.pk)).order_by("pk").values_list("pk")), ) def test_plugin_latest(self): post1 = self._get_post(self._post_data[0]["en"]) self._get_post(self._post_data[1]["en"]) post1.tags.add("tag 1") post1.save() request = self.get_page_request("/", AnonymousUser(), r"/en/blog/", edit=False) request_auth = self.get_page_request("/", self.user_staff, r"/en/blog/", edit=False) request_edit = self.get_page_request("/", self.user_staff, r"/en/blog/", edit=True) plugin = add_plugin(post1.content, "BlogLatestEntriesPlugin", language="en", app_config=self.app_config_1) tag = Tag.objects.get(slug="tag-1") plugin.tags.add(tag) # unauthenticated users get no post self.assertEqual(len(plugin.get_posts(request)), 0) # staff users not in edit mode get no post self.assertEqual(len(plugin.get_posts(request_auth)), 0) # staff users in edit mode get the post self.assertEqual(len(plugin.get_posts(request_edit, published_only=False)), 1) post1.publish = True post1.save() self.assertEqual(len(plugin.get_posts(request)), 1) class ModelsTest2(BaseTest): def test_copy_plugin_latest(self): post1 = self._get_post(self._post_data[0]["en"]) post2 = self._get_post(self._post_data[1]["en"]) tag1 = Tag.objects.create(name="tag 1") tag2 = Tag.objects.create(name="tag 2") plugin = add_plugin(post1.content, "BlogLatestEntriesPlugin", language="en", app_config=self.app_config_1) plugin.tags.add(tag1) plugin.tags.add(tag2) plugins = list(post1.content.cmsplugin_set.filter(language="en").order_by("path", "depth", "position")) copy_plugins_to(plugins, post2.content) new = list(downcast_plugins(post2.content.cmsplugin_set.all())) self.assertEqual(set(new[0].tags.all()), {tag1, tag2}) self.assertEqual(set(new[0].tags.all()), set(plugin.tags.all())) def test_plugin_author(self): post1 = self._get_post(self._post_data[0]["en"]) post2 = self._get_post(self._post_data[1]["en"]) request = self.get_page_request("/", AnonymousUser(), r"/en/blog/", edit=False) plugin = add_plugin(post1.content, "BlogAuthorPostsPlugin", language="en", app_config=self.app_config_1) plugin.authors.add(self.user) self.assertEqual(len(plugin.get_posts(request)), 0) self.assertEqual(plugin.get_authors(request)[0].count, 0) post1.publish = True post1.save() self.assertEqual(len(plugin.get_posts(request)), 1) self.assertEqual(plugin.get_authors(request)[0].count, 1) post2.publish = True post2.save() self.assertEqual(len(plugin.get_posts(request)), 2) self.assertEqual(plugin.get_authors(request)[0].count, 2) def test_plugin_featured_posts(self): post1 = self._get_post(self._post_data[0]["en"]) post1.publish = True post1.save() post2 = self._get_post(self._post_data[1]["en"]) request = self.get_page_request("/", AnonymousUser(), r"/en/blog/", edit=False) plugin = add_plugin(post1.content, "BlogFeaturedPostsPlugin", language="en", app_config=self.app_config_1) plugin.posts.add(post1, post2) self.assertEqual(len(plugin.get_posts(request)), 1) post2.publish = True post2.save() self.assertEqual(len(plugin.get_posts(request)), 2) def test_copy_plugin_featured_post(self): post1 = self._get_post(self._post_data[0]["en"]) post2 = self._get_post(self._post_data[1]["en"]) plugin = add_plugin(post1.content, "BlogFeaturedPostsPlugin", language="en", app_config=self.app_config_1) plugin.posts.add(post1, post2) plugins = list(post1.content.cmsplugin_set.filter(language="en").order_by("path", "depth", "position")) copy_plugins_to(plugins, post2.content) new = list(downcast_plugins(post2.content.cmsplugin_set.all())) self.assertEqual(set(new[0].posts.all()), {post1, post2}) def test_copy_plugin_author(self): post1 = self._get_post(self._post_data[0]["en"]) post2 = self._get_post(self._post_data[1]["en"]) plugin = add_plugin(post1.content, "BlogAuthorPostsPlugin", language="en", app_config=self.app_config_1) plugin.authors.add(self.user) plugins = list(post1.content.cmsplugin_set.filter(language="en").order_by("path", "depth", "position")) copy_plugins_to(plugins, post2.content) new = list(downcast_plugins(post2.content.cmsplugin_set.all())) self.assertEqual(set(new[0].authors.all()), {self.user}) def test_multisite(self): with override("en"): post1 = self._get_post(self._post_data[0]["en"], sites=(self.site_1,)) post2 = self._get_post(self._post_data[1]["en"], sites=(self.site_2,)) post3 = self._get_post(self._post_data[2]["en"], sites=(self.site_2, self.site_1)) self.assertEqual(len(Post.objects.all()), 3) with self.settings(**{"SITE_ID": self.site_1.pk}): self.assertEqual(len(Post.objects.all().on_site()), 2) self.assertEqual(set(Post.objects.all().on_site()), {post1, post3}) with self.settings(**{"SITE_ID": self.site_2.pk}): self.assertEqual(len(Post.objects.all().on_site()), 2) self.assertEqual(set(Post.objects.all().on_site()), {post2, post3}) def test_str_repr(self): self.get_pages() post1 = self._get_post(self._post_data[0]["en"]) post1.meta_description = "" post1.main_image = None post1.save() self.assertEqual(force_str(post1), post1.title) self.assertEqual(post1.get_description(), strip_tags(post1.abstract)) self.assertEqual(post1.get_image_full_url(), "") self.assertEqual(post1.get_author(), self.user) self.assertEqual(force_str(post1.categories.first()), "category 1") plugin = add_plugin(post1.content, "BlogAuthorPostsPlugin", language="en", app_config=self.app_config_1) self.assertEqual(force_str(plugin.__str__()), "5 latest articles by author") plugin = add_plugin(post1.content, "BlogLatestEntriesPlugin", language="en", app_config=self.app_config_1) self.assertEqual(force_str(plugin.__str__()), "5 latest articles by tag") plugin = add_plugin(post1.content, "BlogArchivePlugin", language="en", app_config=self.app_config_1) self.assertEqual(force_str(plugin.__str__()), "generic blog plugin") plugin = add_plugin(post1.content, "BlogFeaturedPostsPlugin", language="en", app_config=self.app_config_1) self.assertEqual(plugin.__str__(), "Featured posts") # create fake empty post - assign a random pk to trick ORM / parler to think the object has been saved # due to how safe_translation_getter works no_translation_post = Post() no_translation_post.pk = 1000000 no_translation_default_title = "Post (no translation)" self.assertEqual(force_str(no_translation_post), no_translation_default_title) class KnockerTest(BaseTest): @classmethod def setUpClass(cls): try: import knocker # noqa super().setUpClass() except ImportError: raise SkipTest("django-knocker not installed, skipping tests") def test_model_attributes(self): self.get_pages() posts = self.get_posts() for language in posts[0].get_available_languages(): with smart_override(language): posts[0].set_current_language(language) knock_create = posts[0].as_knock(signal_type="post_save", created=True) self.assertEqual(knock_create["title"], "new {}".format(posts[0]._meta.verbose_name)) self.assertEqual(knock_create["message"], posts[0].title) self.assertEqual(knock_create["language"], language) for language in posts[0].get_available_languages(): with smart_override(language): posts[0].set_current_language(language) knock_create = posts[0].as_knock(signal_type="post_save", created=False) self.assertEqual(knock_create["title"], "new {}".format(posts[0]._meta.verbose_name)) self.assertEqual(knock_create["message"], posts[0].title) self.assertEqual(knock_create["language"], language) def test_should_knock(self): self.get_pages() post_data = { "author": self.user, "title": "post 1", "abstract": "post 1", "meta_description": "post 1", "meta_keywords": "post 1", "app_config": self.app_config_1, } post = Post.objects.create(**post_data) # Object is not published, no knock self.assertFalse(post.should_knock(signal_type="post_save")) post.publish = True post.save() # Object is published, send knock self.assertTrue(post.should_knock(signal_type="post_save")) # Knock disabled for updates self.app_config_1.app_data.config.send_knock_update = False self.app_config_1.save() post.abstract = "what" post.save() self.assertFalse(post.should_knock(signal_type="post_save")) # Knock disabled for publishing self.app_config_1.app_data.config.send_knock_create = False self.app_config_1.save() post_data = { "author": self.user, "title": "post 2", "abstract": "post 2", "meta_description": "post 2", "meta_keywords": "post 2", "app_config": self.app_config_1, } post = Post.objects.create(**post_data) self.assertFalse(post.should_knock(signal_type="post_save")) post.publish = True post.save() self.assertFalse(post.should_knock(signal_type="post_save")) # Restore default values self.app_config_1.app_data.config.send_knock_create = True self.app_config_1.app_data.config.send_knock_update = True self.app_config_1.save()
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,772
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0038_post_media.py
# Generated by Django 1.11.24 on 2019-09-14 10:45 import cms.models.fields import django.db.models.deletion from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("cms", "0020_old_tree_cleanup"), ("djangocms_blog", "0037_auto_20190806_0743"), ] operations = [ migrations.AddField( model_name="post", name="media", field=cms.models.fields.PlaceholderField( editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name="media", slotname="media", to="cms.Placeholder", ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,773
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0021_post_liveblog.py
import cms.models.fields from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("cms", "0020_old_tree_cleanup"), ("djangocms_blog", "0020_thumbnail_move4"), ] operations = [ migrations.AddField( model_name="post", name="liveblog", field=cms.models.fields.PlaceholderField( related_name="live_blog", slotname="live_blog", editable=False, to="cms.Placeholder", null=True ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,774
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0003_auto_20141201_2252.py
from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0002_post_sites"), ] operations = [ migrations.AlterField( model_name="post", name="sites", field=models.ManyToManyField( help_text="Select sites in which to show the post. If none is set it will " "be visible in all the configured sites.", to="sites.Site", null=True, verbose_name="Site(s)", blank=True, ), preserve_default=True, ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,775
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/sitemaps/__init__.py
from cms.utils import get_language_list from django.contrib.sitemaps import Sitemap from django.urls.exceptions import NoReverseMatch from parler.utils.context import smart_override from ..models import Post from ..settings import get_setting class BlogSitemap(Sitemap): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.url_cache = {} def priority(self, obj): if obj and obj.app_config: return obj.app_config.sitemap_priority return get_setting("SITEMAP_PRIORITY_DEFAULT") def changefreq(self, obj): if obj and obj.app_config: return obj.app_config.sitemap_changefreq return get_setting("SITEMAP_CHANGEFREQ_DEFAULT") def location(self, obj): with smart_override(obj.get_current_language()): return self.url_cache[obj.get_current_language()][obj] def items(self): items = [] self.url_cache.clear() for lang in get_language_list(): self.url_cache[lang] = {} posts = Post.objects.translated(lang).language(lang).published() for post in posts: # check if the post actually has a url before appending # if a post is published but the associated app config is not # then this post will not have a url try: with smart_override(post.get_current_language()): self.url_cache[lang][post] = post.get_absolute_url() except NoReverseMatch: # couldn't determine the url of the post so pass on it continue items.append(post) return items def lastmod(self, obj): return obj.date_modified
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,776
fsbraun/djangocms-blog
refs/heads/develop
/tests/media_app/models.py
import re import requests from cms.models import CMSPlugin from django.db import models from djangocms_blog.media.base import MediaAttachmentPluginMixin class YoutTubeVideo(MediaAttachmentPluginMixin, CMSPlugin): url = models.URLField("video URL") _media_autoconfiguration = { "params": [ re.compile("^https://youtu.be/(?P<media_id>[-\\w]+)$"), re.compile("^https://www.youtube.com/watch\\?v=(?P<media_id>[-\\w]+)$"), ], "thumb_url": "https://img.youtube.com/vi/%(media_id)s/hqdefault.jpg", "main_url": "https://img.youtube.com/vi/%(media_id)s/maxresdefault.jpg", "callable": None, } def __str__(self): return self.url @property def media_url(self): return self.url class Vimeo(MediaAttachmentPluginMixin, CMSPlugin): url = models.URLField("Video URL") _media_autoconfiguration = { "params": [re.compile("^https://vimeo.com/(?P<media_id>[-0-9]+)$")], "thumb_url": "%(thumb_url)s", "main_url": "%(main_url)s", "callable": "vimeo_data", } def __str__(self): return self.url @property def media_url(self): return self.url @property def media_title(self): try: return self.media_params["title"] except KeyError: return None def vimeo_data(self, media_id): response = requests.get( "https://vimeo.com/api/v2/video/{media_id}.json".format( media_id=media_id, ) ) json = response.json() data = {} if json: data = json[0] data.update( {"media_id": media_id, "main_url": data["thumbnail_large"], "thumb_url": data["thumbnail_medium"]} ) return data
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,777
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0026_merge.py
# Generated by Django 1.9.9 on 2016-08-25 20:24 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0021_auto_20160823_2008"), ("djangocms_blog", "0025_auto_20160803_0858"), ] operations = []
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,778
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_indexing.py
from unittest import skipIf from cms.api import add_plugin from django.test import override_settings from djangocms_blog.models import Post from .base import BaseTest try: import aldryn_search except ImportError: aldryn_search = None try: import haystack from haystack.constants import DEFAULT_ALIAS from haystack.query import SearchQuerySet except ImportError: haystack = None class BlogIndexingTests(BaseTest): sample_text = "First post first line This is the description keyword1 keyword2 category 1 a tag test body" def setUp(self): self.get_pages() super().setUp() @skipIf(aldryn_search is None, "aldryn-search not installed") @skipIf(haystack is None, "haystack not installed") def test_blog_post_is_indexed_using_prepare(self): """This tests the indexing path way used by update_index mgmt command""" post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") post.tags.add("a tag") add_plugin(post.content, "TextPlugin", language="en", body="test body") index = self.get_post_index() index.index_queryset(DEFAULT_ALIAS) # initialises index._backend_alias indexed = index.prepare(post) self.assertEqual(post.get_title(), indexed["title"]) self.assertEqual(post.get_description(), indexed["description"]) self.assertEqual(post.get_tags(), indexed["tags"]) self.assertEqual(self.sample_text, indexed["text"]) self.assertEqual(post.get_absolute_url(), indexed["url"]) self.assertEqual(post.date_published, indexed["pub_date"]) @skipIf(aldryn_search is None, "aldryn-search not installed") @skipIf(haystack is None, "haystack not installed") @override_settings(BLOG_USE_PLACEHOLDER=False) def test_blog_post_is_indexed_using_prepare_no_placeholder(self): """This tests the indexing path way used by update_index mgmt command when not using placeholder content""" post = self._get_post(self._post_data[0]["en"]) post = self._get_post(self._post_data[0]["it"], post, "it") post.tags.add("a tag") add_plugin(post.content, "TextPlugin", language="en", body="test body") post.post_text = "non placeholder content" index = self.get_post_index() index.index_queryset(DEFAULT_ALIAS) # initialises index._backend_alias indexed = index.prepare(post) self.assertEqual(post.get_title(), indexed["title"]) self.assertEqual(post.get_description(), indexed["description"]) self.assertEqual(post.get_tags(), indexed["tags"]) self.assertNotEqual(self.sample_text, indexed["text"]) self.assertTrue(post.post_text in indexed["text"]) self.assertEqual(post.get_absolute_url(), indexed["url"]) self.assertEqual(post.date_published, indexed["pub_date"]) @skipIf(haystack is None, "haystack not installed") def test_searchqueryset(self): posts = self.get_posts() all_results = SearchQuerySet().models(Post) self.assertEqual(len(posts), len(all_results))
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,779
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/liveblog/migrations/0003_auto_20160917_0123.py
# Generated by Django 1.9.9 on 2016-09-16 23:23 import django.db.models.deletion import django.utils.timezone from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("liveblog", "0002_liveblog_title"), ] operations = [ migrations.AddField( model_name="liveblog", name="post_date", field=models.DateTimeField(blank=True, default=django.utils.timezone.now, verbose_name="post date"), ), migrations.AlterField( model_name="liveblog", name="cmsplugin_ptr", field=models.OneToOneField( on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name="liveblog_liveblog", serialize=False, to="cms.CMSPlugin", ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,780
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0042_alter_authorentriesplugin_cmsplugin_ptr_and_more.py
# Generated by Django 4.2.3 on 2023-08-04 09:10 import aldryn_apphooks_config.fields import django.db.models.deletion import sortedm2m.fields from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("cms", "0022_auto_20180620_1551"), ("djangocms_blog", "0041_auto_20230720_1508"), ] operations = [ migrations.AlterField( model_name="authorentriesplugin", name="cmsplugin_ptr", field=models.OneToOneField( auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name="%(app_label)s_%(class)s", serialize=False, to="cms.cmsplugin", ), ), migrations.AlterField( model_name="genericblogplugin", name="cmsplugin_ptr", field=models.OneToOneField( auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name="%(app_label)s_%(class)s", serialize=False, to="cms.cmsplugin", ), ), migrations.AlterField( model_name="latestpostsplugin", name="cmsplugin_ptr", field=models.OneToOneField( auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name="%(app_label)s_%(class)s", serialize=False, to="cms.cmsplugin", ), ), migrations.CreateModel( name="FeaturedPostsPlugin", fields=[ ( "cmsplugin_ptr", models.OneToOneField( auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name="%(app_label)s_%(class)s", serialize=False, to="cms.cmsplugin", ), ), ( "current_site", models.BooleanField( default=True, help_text="Select items from the current site only", verbose_name="current site" ), ), ( "template_folder", models.CharField( choices=[("plugins", "Default template")], default="plugins", help_text="Select plugin template to load for this instance", max_length=200, verbose_name="Plugin template", ), ), ( "app_config", aldryn_apphooks_config.fields.AppHookConfigField( blank=True, help_text="When selecting a value, the form is reloaded to get the updated default", null=True, on_delete=django.db.models.deletion.CASCADE, to="djangocms_blog.blogconfig", verbose_name="app. config", ), ), ( "posts", sortedm2m.fields.SortedManyToManyField( help_text=None, to="djangocms_blog.post", verbose_name="Featured posts" ), ), ], options={ "abstract": False, }, bases=("cms.cmsplugin",), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,781
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0005_auto_20150212_1118.py
import cms.models.fields from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0004_auto_20150108_1435"), ] operations = [ migrations.AlterField( model_name="post", name="content", field=cms.models.fields.PlaceholderField( slotname="post_content", to="cms.Placeholder", null=True, related_name="post_content", editable=False ), preserve_default=True, ), migrations.AlterField( model_name="post", name="enable_comments", field=models.BooleanField(default=False, verbose_name="Enable comments on post"), preserve_default=True, ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,782
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/feeds.py
from html import unescape from io import BytesIO from aldryn_apphooks_config.utils import get_app_instance from django.contrib.sites.models import Site from django.contrib.syndication.views import Feed from django.core.cache import cache from django.urls import reverse from django.utils.encoding import force_str from django.utils.feedgenerator import Rss201rev2Feed from django.utils.html import strip_tags from django.utils.safestring import mark_safe from django.utils.text import normalize_newlines from django.utils.translation import get_language_from_request, gettext as _ from lxml import etree from djangocms_blog.settings import get_setting from djangocms_blog.views import PostDetailView from .models import Post class LatestEntriesFeed(Feed): feed_type = Rss201rev2Feed feed_items_number = get_setting("FEED_LATEST_ITEMS") def __call__(self, request, *args, **kwargs): self.request = request self.namespace, self.config = get_app_instance(request) return super().__call__(request, *args, **kwargs) def link(self): return reverse("%s:posts-latest" % self.namespace, current_app=self.namespace) def title(self): return Site.objects.get_current().name def description(self): return _("Blog articles on %(site_name)s") % {"site_name": Site.objects.get_current().name} def items(self, obj=None): return ( Post.objects.namespace(self.namespace) .published_on_rss() .order_by("-date_published")[: self.feed_items_number] ) def item_title(self, item): return mark_safe(item.safe_translation_getter("title")) def item_description(self, item): if item.app_config.use_abstract: return mark_safe(item.safe_translation_getter("abstract")) return mark_safe(item.safe_translation_getter("post_text")) def item_updateddate(self, item): return item.date_modified def item_pubdate(self, item): return item.date_published def item_guid(self, item): return item.guid def item_author_name(self, item): return item.get_author_name() def item_author_url(self, item): return item.get_author_url() class TagFeed(LatestEntriesFeed): feed_items_number = get_setting("FEED_TAGS_ITEMS") def get_object(self, request, tag): return tag # pragma: no cover def items(self, obj=None): return Post.objects.published().filter(tags__slug=obj)[: self.feed_items_number] class FBInstantFeed(Rss201rev2Feed): date_format = "%Y-%m-%dT%H:%M:%S%z" def rss_attributes(self): return {"version": self._version, "xmlns:content": "http://purl.org/rss/1.0/modules/content/"} def add_root_elements(self, handler): handler.addQuickElement("title", self.feed["title"]) handler.addQuickElement("link", self.feed["link"]) handler.addQuickElement("description", self.feed["description"]) if self.feed["language"] is not None: handler.addQuickElement("language", self.feed["language"]) for cat in self.feed["categories"]: handler.addQuickElement("category", cat) if self.feed["feed_copyright"] is not None: handler.addQuickElement("copyright", self.feed["feed_copyright"]) handler.addQuickElement("lastBuildDate", self.latest_post_date().strftime(self.date_format)) if self.feed["ttl"] is not None: handler.addQuickElement("ttl", self.feed["ttl"]) def add_item_elements(self, handler, item): super().add_item_elements(handler, item) if item["author"]: handler.addQuickElement("author", item["author"]) if item["date_pub"] is not None: handler.addQuickElement("pubDate", item["date_pub"].strftime(self.date_format)) if item["date_mod"] is not None: handler.addQuickElement("modDate", item["date_mod"].strftime(self.date_format)) handler.startElement("description", {}) handler._write( "<![CDATA[{}]]>".format(unescape(normalize_newlines(force_str(item["abstract"])).replace("\n", " "))) ) handler.endElement("description") handler.startElement("content:encoded", {}) handler._write("<![CDATA[") handler._write("<!doctype html>") handler._write(unescape(force_str(item["content"]))) handler._write("]]>") handler.endElement("content:encoded") class FBInstantArticles(LatestEntriesFeed): feed_type = FBInstantFeed feed_items_number = get_setting("FEED_INSTANT_ITEMS") def items(self, obj=None): return Post.objects.namespace(self.namespace).published().order_by("-date_modified")[: self.feed_items_number] def _clean_html(self, content): body = BytesIO(content) document = etree.iterparse(body, html=True) for _a, element in document: if not (element.text and element.text.strip()) and len(element) == 0 and element.tag == "p": element.getparent().remove(element) if element.tag in ("h3", "h4", "h5", "h6") and "op-kicker" not in element.attrib.get("class", ""): element.tag = "h2" return etree.tostring(document.root) def item_extra_kwargs(self, item): if not item: return {} language = get_language_from_request(self.request, check_path=True) key = item.get_cache_key(language, "feed") content = cache.get(key) if not content: view = PostDetailView.as_view(instant_article=True) response = view(self.request, slug=item.safe_translation_getter("slug")) response.render() content = self._clean_html(response.content) cache.set(key, content, timeout=get_setting("FEED_CACHE_TIMEOUT")) if item.app_config.use_abstract: abstract = strip_tags(item.safe_translation_getter("abstract")) else: abstract = strip_tags(item.safe_translation_getter("post_text")) return { "author": item.get_author_name(), "content": content, "date": item.date_modified, "date_pub": item.date_modified, "date_mod": item.date_modified, "abstract": abstract, } def item_categories(self, item): return [category.safe_translation_getter("name") for category in item.categories.all()] def item_author_name(self, item): return "" def item_author_url(self, item): return "" def item_description(self, item): return None def item_pubdate(self, item): return None
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,783
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0017_thumbnail_move.py
from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("filer", "0003_thumbnailoption"), ("djangocms_blog", "0016_auto_20160502_1741"), ] operations = []
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,784
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/views.py
import os.path from aldryn_apphooks_config.mixins import AppConfigMixin from django.apps import apps from django.contrib.auth import get_user_model from django.core.exceptions import ImproperlyConfigured from django.http import Http404 from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils.timezone import now from django.utils.translation import get_language from django.views.generic import DetailView, ListView from parler.views import TranslatableSlugMixin, ViewUrlMixin from .models import BlogCategory, Post from .settings import get_setting User = get_user_model() class BaseBlogView(AppConfigMixin, ViewUrlMixin): model = Post def optimize(self, qs): """ Apply select_related / prefetch_related to optimize the view queries :param qs: queryset to optimize :return: optimized queryset """ return qs.select_related("app_config").prefetch_related( "translations", "categories", "categories__translations", "categories__app_config" ) def get_view_url(self): if not self.view_url_name: raise ImproperlyConfigured("Missing `view_url_name` attribute on {}".format(self.__class__.__name__)) url = reverse(self.view_url_name, args=self.args, kwargs=self.kwargs, current_app=self.namespace) return self.request.build_absolute_uri(url) def get_queryset(self): language = get_language() queryset = self.model._default_manager.namespace(self.namespace).active_translations(language_code=language) if not getattr(self.request, "toolbar", None) or not self.request.toolbar.edit_mode_active: queryset = queryset.published() setattr(self.request, get_setting("CURRENT_NAMESPACE"), self.config) return self.optimize(queryset.on_site()) def get_template_names(self): template_path = (self.config and self.config.template_prefix) or "djangocms_blog" return os.path.join(template_path, self.base_template_name) class BaseBlogListView(BaseBlogView): context_object_name = "post_list" base_template_name = "post_list.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["TRUNCWORDS_COUNT"] = get_setting("POSTS_LIST_TRUNCWORDS_COUNT") return context def get_paginate_by(self, queryset): return (self.config and self.config.paginate_by) or get_setting("PAGINATION") class PostDetailView(TranslatableSlugMixin, BaseBlogView, DetailView): context_object_name = "post" base_template_name = "post_detail.html" slug_field = "slug" view_url_name = "djangocms_blog:post-detail" instant_article = False def liveblog_enabled(self): return self.object.enable_liveblog and apps.is_installed("djangocms_blog.liveblog") def get_template_names(self): if self.instant_article: template_path = (self.config and self.config.template_prefix) or "djangocms_blog" return os.path.join(template_path, "post_instant_article.html") else: return super().get_template_names() def get_queryset(self): queryset = self.model._default_manager.all() if not getattr(self.request, "toolbar", None) or not self.request.toolbar.edit_mode_active: queryset = queryset.published() return self.optimize(queryset.on_site()) def get(self, *args, **kwargs): # submit object to cms to get corrent language switcher and selected category behavior if hasattr(self.request, "toolbar"): self.request.toolbar.set_object(self.get_object()) return super().get(*args, **kwargs) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["meta"] = self.get_object().as_meta() context["instant_article"] = self.instant_article context["use_placeholder"] = get_setting("USE_PLACEHOLDER") setattr(self.request, get_setting("CURRENT_POST_IDENTIFIER"), self.get_object()) return context class PostListView(BaseBlogListView, ListView): view_url_name = "djangocms_blog:posts-latest" class PostArchiveView(BaseBlogListView, ListView): date_field = "date_published" allow_empty = True allow_future = True view_url_name = "djangocms_blog:posts-archive" def get_queryset(self): qs = super().get_queryset() if "month" in self.kwargs: qs = qs.filter(**{"%s__month" % self.date_field: self.kwargs["month"]}) if "year" in self.kwargs: qs = qs.filter(**{"%s__year" % self.date_field: self.kwargs["year"]}) return self.optimize(qs) def get_context_data(self, **kwargs): kwargs["month"] = int(self.kwargs.get("month")) if "month" in self.kwargs else None kwargs["year"] = int(self.kwargs.get("year")) if "year" in self.kwargs else None if kwargs["year"]: kwargs["archive_date"] = now().replace(kwargs["year"], kwargs["month"] or 1, 1) context = super().get_context_data(**kwargs) return context class TaggedListView(BaseBlogListView, ListView): view_url_name = "djangocms_blog:posts-tagged" def get_queryset(self): qs = super().get_queryset() return self.optimize(qs.filter(tags__slug=self.kwargs["tag"])) def get_context_data(self, **kwargs): kwargs["tagged_entries"] = self.kwargs.get("tag") if "tag" in self.kwargs else None context = super().get_context_data(**kwargs) return context class AuthorEntriesView(BaseBlogListView, ListView): view_url_name = "djangocms_blog:posts-author" def get_queryset(self): qs = super().get_queryset() if "username" in self.kwargs: qs = qs.filter(**{"author__%s" % User.USERNAME_FIELD: self.kwargs["username"]}) return self.optimize(qs) def get_context_data(self, **kwargs): kwargs["author"] = get_object_or_404(User, **{User.USERNAME_FIELD: self.kwargs.get("username")}) context = super().get_context_data(**kwargs) return context class CategoryEntriesView(BaseBlogListView, ListView): _category = None view_url_name = "djangocms_blog:posts-category" @property def category(self): if not self._category: try: self._category = BlogCategory.objects.active_translations( get_language(), slug=self.kwargs["category"] ).get() except BlogCategory.DoesNotExist: raise Http404 return self._category def get(self, *args, **kwargs): # submit object to cms toolbar to get correct language switcher behavior if hasattr(self.request, "toolbar"): self.request.toolbar.set_object(self.category) return super().get(*args, **kwargs) def get_queryset(self): qs = super().get_queryset() if "category" in self.kwargs: qs = qs.filter(categories=self.category.pk) return self.optimize(qs) def get_context_data(self, **kwargs): kwargs["category"] = self.category context = super().get_context_data(**kwargs) context["meta"] = self.category.as_meta() return context
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,785
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0032_auto_20180109_0023.py
# Generated by Django 1.10.8 on 2018-01-08 23:23 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0031_auto_20170610_1744"), ] operations = [ migrations.AddField( model_name="blogcategorytranslation", name="meta_description", field=models.TextField(blank=True, default="", verbose_name="post meta description"), ), migrations.AlterField( model_name="blogcategorytranslation", name="name", field=models.CharField(max_length=752, verbose_name="name"), ), migrations.AlterField( model_name="blogcategorytranslation", name="slug", field=models.SlugField(blank=True, max_length=752, verbose_name="slug"), ), migrations.AlterField( model_name="posttranslation", name="meta_title", field=models.CharField( blank=True, default="", help_text="used in title tag and social sharing", max_length=2000, verbose_name="post meta title", ), ), migrations.AlterField( model_name="posttranslation", name="slug", field=models.SlugField( allow_unicode=True, blank=True, db_index=False, max_length=752, verbose_name="slug" ), ), migrations.AlterField( model_name="posttranslation", name="title", field=models.CharField(max_length=752, verbose_name="title"), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,786
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0027_post_date_featured.py
# Generated by Django 1.10.5 on 2017-01-25 11:15 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0026_merge"), ] operations = [ migrations.AddField( model_name="post", name="date_featured", field=models.DateTimeField(blank=True, null=True, verbose_name="featured date"), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,787
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0021_auto_20160823_2008.py
import django.db.models.deletion from django.db import migrations, models from djangocms_blog.models import thumbnail_model class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0020_thumbnail_move4"), ] operations = [ migrations.AlterField( model_name="authorentriesplugin", name="cmsplugin_ptr", field=models.OneToOneField( parent_link=True, related_name="djangocms_blog_authorentriesplugin", auto_created=True, primary_key=True, serialize=False, to="cms.CMSPlugin", on_delete=models.deletion.CASCADE, ), ), migrations.AlterField( model_name="genericblogplugin", name="cmsplugin_ptr", field=models.OneToOneField( parent_link=True, related_name="djangocms_blog_genericblogplugin", auto_created=True, primary_key=True, serialize=False, to="cms.CMSPlugin", on_delete=models.deletion.CASCADE, ), ), migrations.AlterField( model_name="latestpostsplugin", name="cmsplugin_ptr", field=models.OneToOneField( parent_link=True, related_name="djangocms_blog_latestpostsplugin", auto_created=True, primary_key=True, serialize=False, to="cms.CMSPlugin", on_delete=models.deletion.CASCADE, ), ), migrations.AlterField( model_name="post", name="main_image_full", field=models.ForeignKey( related_name="djangocms_blog_post_full", on_delete=django.db.models.deletion.SET_NULL, verbose_name="main image full", blank=True, to=thumbnail_model, null=True, ), ), migrations.AlterField( model_name="post", name="main_image_thumbnail", field=models.ForeignKey( related_name="djangocms_blog_post_thumbnail", on_delete=django.db.models.deletion.SET_NULL, verbose_name="main image thumbnail", blank=True, to=thumbnail_model, null=True, ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,788
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/cms_plugins.py
import os.path from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from django.contrib.sites.shortcuts import get_current_site from django.db import models from django.template.loader import select_template from .forms import AuthorPostsForm, BlogPluginForm, LatestEntriesForm from .models import AuthorEntriesPlugin, BlogCategory, FeaturedPostsPlugin, GenericBlogPlugin, LatestPostsPlugin, Post from .settings import get_setting class BlogPlugin(CMSPluginBase): module = get_setting("PLUGIN_MODULE_NAME") form = BlogPluginForm def get_render_template(self, context, instance, placeholder): """ Select the template used to render the plugin. Check the default folder as well as the folders provided to the apphook config. """ templates = [os.path.join("djangocms_blog", instance.template_folder, self.base_render_template)] if instance.app_config and instance.app_config.template_prefix: templates.insert( 0, os.path.join(instance.app_config.template_prefix, instance.template_folder, self.base_render_template), ) selected = select_template(templates) return selected.template.name @plugin_pool.register_plugin class BlogLatestEntriesPlugin(BlogPlugin): """ Return the latest published posts which bypasses cache, taking into account the user / toolbar state. """ name = get_setting("LATEST_ENTRIES_PLUGIN_NAME") model = LatestPostsPlugin form = LatestEntriesForm filter_horizontal = ("categories",) cache = False base_render_template = "latest_entries.html" def get_fields(self, request, obj=None): """ Return the fields available when editing the plugin. 'template_folder' field is added if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains multiple folders. """ fields = ["app_config", "latest_posts", "tags", "categories"] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1: fields.append("template_folder") return fields def render(self, context, instance, placeholder): """Render the plugin.""" context = super().render(context, instance, placeholder) context["posts_list"] = instance.get_posts(context["request"], published_only=False) context["TRUNCWORDS_COUNT"] = get_setting("POSTS_LIST_TRUNCWORDS_COUNT") return context @plugin_pool.register_plugin class BlogLatestEntriesPluginCached(BlogLatestEntriesPlugin): """ Return the latest published posts caching the result. """ name = get_setting("LATEST_ENTRIES_PLUGIN_NAME_CACHED") cache = True @plugin_pool.register_plugin class BlogFeaturedPostsPlugin(BlogPlugin): """ Return the selected posts which bypasses cache. """ name = get_setting("FEATURED_POSTS_PLUGIN_NAME") model = FeaturedPostsPlugin form = BlogPluginForm cache = False base_render_template = "featured_posts.html" def get_fields(self, request, obj=None): """ Return the fields available when editing the plugin. 'template_folder' field is added if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains multiple folders. """ fields = ["app_config", "posts"] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1: fields.append("template_folder") return fields def render(self, context, instance, placeholder): """Render the plugin.""" context = super().render(context, instance, placeholder) context["posts_list"] = instance.get_posts(context["request"]) context["TRUNCWORDS_COUNT"] = get_setting("POSTS_LIST_TRUNCWORDS_COUNT") return context @plugin_pool.register_plugin class BlogFeaturedPostsPluginCached(BlogFeaturedPostsPlugin): """ Return the selected posts caching the result. """ name = get_setting("FEATURED_POSTS_PLUGIN_NAME_CACHED") cache = True @plugin_pool.register_plugin class BlogAuthorPostsPlugin(BlogPlugin): """Render the list of authors.""" module = get_setting("PLUGIN_MODULE_NAME") name = get_setting("AUTHOR_POSTS_PLUGIN_NAME") model = AuthorEntriesPlugin form = AuthorPostsForm base_render_template = "authors.html" filter_horizontal = ["authors"] def get_fields(self, request, obj=None): """ Return the fields available when editing the plugin. 'template_folder' field is added if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains multiple folders. """ fields = ["app_config", "current_site", "authors"] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1: fields.append("template_folder") return fields def render(self, context, instance, placeholder): """Render the plugin.""" context = super().render(context, instance, placeholder) context["authors_list"] = instance.get_authors(context["request"]) return context @plugin_pool.register_plugin class BlogAuthorPostsListPlugin(BlogAuthorPostsPlugin): """Render the list of posts for each selected author.""" name = get_setting("AUTHOR_POSTS_LIST_PLUGIN_NAME") base_render_template = "authors_posts.html" fields = ( ["app_config", "current_site", "authors", "latest_posts"] + ["template_folder"] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1 else [] ) def get_fields(self, request, obj=None): """ Return the fields available when editing the plugin. 'template_folder' field is added if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains multiple folders. """ fields = ["app_config", "current_site", "authors", "latest_posts"] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1: fields.append("template_folder") return fields @plugin_pool.register_plugin class BlogTagsPlugin(BlogPlugin): """Render the list of post tags.""" module = get_setting("PLUGIN_MODULE_NAME") name = get_setting("TAGS_PLUGIN_NAME") model = GenericBlogPlugin base_render_template = "tags.html" def get_exclude(self, request, obj=None): """Exclude 'template_folder' field if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains one folder.""" return [] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1 else ["template_folder"] def render(self, context, instance, placeholder): """Render the plugin.""" context = super().render(context, instance, placeholder) qs = instance.post_queryset(context["request"]) context["tags"] = Post.objects.tag_cloud(queryset=qs.published()) return context @plugin_pool.register_plugin class BlogCategoryPlugin(BlogPlugin): """Render the list of post categories.""" module = get_setting("PLUGIN_MODULE_NAME") name = get_setting("CATEGORY_PLUGIN_NAME") model = GenericBlogPlugin base_render_template = "categories.html" def get_exclude(self, request, obj=None): """Exclude 'template_folder' field if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains one folder.""" return [] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1 else ["template_folder"] def render(self, context, instance, placeholder): """Render the plugin.""" context = super().render(context, instance, placeholder) qs = BlogCategory.objects.active_translations() if instance.app_config: qs = qs.namespace(instance.app_config.namespace) if instance.current_site: site = get_current_site(context["request"]) qs = qs.filter(models.Q(blog_posts__sites__isnull=True) | models.Q(blog_posts__sites=site.pk)) categories = qs.distinct() if instance.app_config and not instance.app_config.menu_empty_categories: categories = qs.filter(blog_posts__isnull=False).distinct() context["categories"] = categories return context @plugin_pool.register_plugin class BlogArchivePlugin(BlogPlugin): """Render the list of months with available posts.""" module = get_setting("PLUGIN_MODULE_NAME") name = get_setting("ARCHIVE_PLUGIN_NAME") model = GenericBlogPlugin base_render_template = "archive.html" def get_exclude(self, request, obj=None): """Exclude 'template_folder' field if ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` contains one folder.""" return [] if len(get_setting("PLUGIN_TEMPLATE_FOLDERS")) > 1 else ["template_folder"] def render(self, context, instance, placeholder): """Render the plugin.""" context = super().render(context, instance, placeholder) qs = instance.post_queryset(context["request"]) context["dates"] = Post.objects.get_months(queryset=qs.published()) return context
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,789
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0008_auto_20150814_0831.py
import djangocms_text_ckeditor.fields from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0007_auto_20150719_0933"), ] operations = [ migrations.AlterField( model_name="posttranslation", name="abstract", field=djangocms_text_ckeditor.fields.HTMLField(default=b"", verbose_name="abstract", blank=True), preserve_default=True, ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,790
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0024_auto_20160706_1524.py
from django.db import migrations, models from djangocms_blog.settings import get_setting BLOG_PLUGIN_TEMPLATE_FOLDERS = get_setting("PLUGIN_TEMPLATE_FOLDERS") class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0023_auto_20160626_1539"), ] operations = [ migrations.AddField( model_name="authorentriesplugin", name="template_folder", field=models.CharField( default=BLOG_PLUGIN_TEMPLATE_FOLDERS[0][0], verbose_name="Plugin template", max_length=200, help_text="Select plugin template to load for this instance", choices=BLOG_PLUGIN_TEMPLATE_FOLDERS, ), ), migrations.AddField( model_name="genericblogplugin", name="template_folder", field=models.CharField( default=BLOG_PLUGIN_TEMPLATE_FOLDERS[0][0], verbose_name="Plugin template", max_length=200, help_text="Select plugin template to load for this instance", choices=BLOG_PLUGIN_TEMPLATE_FOLDERS, ), ), migrations.AddField( model_name="latestpostsplugin", name="template_folder", field=models.CharField( default=BLOG_PLUGIN_TEMPLATE_FOLDERS[0][0], verbose_name="Plugin template", max_length=200, help_text="Select plugin template to load for this instance", choices=BLOG_PLUGIN_TEMPLATE_FOLDERS, ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,791
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/cms_toolbars.py
from cms.toolbar_base import CMSToolbar from cms.toolbar_pool import toolbar_pool from cms.utils.urlutils import admin_reverse from django.urls import reverse from django.utils.translation import gettext_lazy as _, override from .settings import get_setting @toolbar_pool.register class BlogToolbar(CMSToolbar): def populate(self): if ( not self.is_current_app and not get_setting("ENABLE_THROUGH_TOOLBAR_MENU") ) or not self.request.user.has_perm("djangocms_blog.add_post"): return # pragma: no cover admin_menu = self.toolbar.get_or_create_menu("djangocms_blog", _("Blog")) with override(self.current_lang): url = reverse("admin:djangocms_blog_post_changelist") admin_menu.add_modal_item(_("Post list"), url=url) url = reverse("admin:djangocms_blog_blogcategory_changelist") admin_menu.add_modal_item(_("Category list"), url=url) url = reverse("admin:taggit_tag_changelist") admin_menu.add_modal_item(_("Tag list"), url=url) url = reverse("admin:djangocms_blog_post_add") admin_menu.add_modal_item(_("Add post"), url=url) current_config = getattr(self.request, get_setting("CURRENT_NAMESPACE"), None) if current_config: url = reverse("admin:djangocms_blog_blogconfig_change", args=(current_config.pk,)) admin_menu.add_modal_item(_("Edit configuration"), url=url) current_post = getattr(self.request, get_setting("CURRENT_POST_IDENTIFIER"), None) if current_post and self.request.user.has_perm("djangocms_blog.change_post"): # pragma: no cover # NOQA admin_menu.add_modal_item( _("Edit Post"), reverse("admin:djangocms_blog_post_change", args=(current_post.pk,)), active=True ) def add_publish_button(self): """ Adds the publish button to the toolbar if the current post is unpublished """ current_post = getattr(self.request, get_setting("CURRENT_POST_IDENTIFIER"), None) if ( self.toolbar.edit_mode_active and current_post and not current_post.publish and self.request.user.has_perm("djangocms_blog.change_post") ): # pragma: no cover # NOQA classes = ["cms-btn-action", "blog-publish"] title = _("Publish {0} now").format(current_post.app_config.object_name) url = admin_reverse("djangocms_blog_publish_article", args=(current_post.pk,)) self.toolbar.add_button(title, url=url, extra_classes=classes, side=self.toolbar.RIGHT) def post_template_populate(self): current_post = getattr(self.request, get_setting("CURRENT_POST_IDENTIFIER"), None) if current_post and self.request.user.has_perm("djangocms_blog.change_post"): # pragma: no cover # NOQA # removing page meta menu, if present, to avoid confusion try: # pragma: no cover import djangocms_page_meta # NOQA menu = self.request.toolbar.get_or_create_menu("page") pagemeta = menu.get_or_create_menu("pagemeta", "meta") menu.remove_item(pagemeta) except ImportError: pass # removing page tags menu, if present, to avoid confusion try: # pragma: no cover import djangocms_page_tags # NOQA menu = self.request.toolbar.get_or_create_menu("page") pagetags = menu.get_or_create_menu("pagetags", "tags") menu.remove_item(pagetags) except ImportError: pass self.add_publish_button()
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,792
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/cms_wizards.py
import warnings from cms.api import add_plugin from cms.utils.permissions import get_current_user from cms.wizards.wizard_base import Wizard from cms.wizards.wizard_pool import AlreadyRegisteredException, wizard_pool from django import forms from django.conf import settings from django.utils.translation import gettext_lazy as _ from .cms_appconfig import BlogConfig from .fields import slugify from .forms import PostAdminFormBase from .models import Post from .settings import get_setting class PostWizardForm(PostAdminFormBase): default_appconfig = None slug = forms.SlugField( label=_("Slug"), max_length=752, required=False, help_text=_("Leave empty for automatic slug, or override as required."), ) def __init__(self, *args, **kwargs): if "initial" not in kwargs or not kwargs.get("initial", False): kwargs["initial"] = {} kwargs["initial"]["app_config"] = self.default_appconfig if "data" in kwargs and kwargs["data"] is not None: data = kwargs["data"].copy() data["1-app_config"] = self.default_appconfig kwargs["data"] = data super().__init__(*args, **kwargs) self.fields["app_config"].widget = forms.Select( attrs=self.fields["app_config"].widget.attrs, choices=self.fields["app_config"].widget.choices, ) self.fields["app_config"].widget.attrs["disabled"] = True if "categories" in self.fields: self.fields["categories"].queryset = self.available_categories class Meta: model = Post fields = ["app_config", "title", "slug", "abstract", "categories"] class Media: js = ( "admin/js/vendor/jquery/jquery.js", "admin/js/jquery.init.js", ) def save(self, commit=True): self.instance._set_default_author(get_current_user()) instance = super().save(commit) self.add_plugin() return instance def clean_slug(self): """ Generate a valid slug, in case the given one is taken """ source = self.cleaned_data.get("slug", "") lang_choice = self.language_code if not source: source = slugify(self.cleaned_data.get("title", "")) qs = Post._default_manager.active_translations(lang_choice).language(lang_choice) used = list(qs.values_list("translations__slug", flat=True)) slug = source i = 1 while slug in used: slug = "{}-{}".format(source, i) i += 1 return slug def add_plugin(self): """ Add text field content as text plugin to the blog post. """ text = self.cleaned_data.get("post_text", "") app_config = self.cleaned_data.get("app_config", None) plugin_type = get_setting("WIZARD_CONTENT_PLUGIN") plugin_body = get_setting("WIZARD_CONTENT_PLUGIN_BODY") if text and app_config.use_placeholder: opts = { "placeholder": self.instance.content, "plugin_type": plugin_type, "language": self.language_code, plugin_body: text, } add_plugin(**opts) class PostWizard(Wizard): pass for config in BlogConfig.objects.all().order_by("namespace"): seed = slugify("{}.{}".format(config.app_title, config.namespace)) new_wizard = type(str(seed), (PostWizard,), {}) new_form = type("{}Form".format(seed), (PostWizardForm,), {"default_appconfig": config.pk}) post_wizard = new_wizard( title=_("New {0}").format(config.object_name), weight=200, form=new_form, model=Post, description=_("Create a new {0} in {1}").format(config.object_name, config.app_title), ) try: wizard_pool.register(post_wizard) except AlreadyRegisteredException: # pragma: no cover if settings.DEBUG: raise else: warnings.warn( f"Wizard {seed} cannot be registered. Please make sure that " f"BlogConfig.namespace {config.namespace} and BlogConfig.app_title {config.app_title} are" "unique together", stacklevel=2, )
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,793
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/cms_menus.py
import logging from cms.apphook_pool import apphook_pool from cms.menu_bases import CMSAttachMenu from django.contrib.sites.shortcuts import get_current_site from django.db.models.signals import post_delete, post_save from django.urls import resolve from django.utils.translation import get_language_from_request, gettext_lazy as _ from menus.base import Modifier, NavigationNode from menus.menu_pool import menu_pool from .cms_appconfig import BlogConfig from .models import BlogCategory, Post from .settings import MENU_TYPE_CATEGORIES, MENU_TYPE_COMPLETE, MENU_TYPE_NONE, MENU_TYPE_POSTS, get_setting logger = logging.getLogger(__name__) class BlogCategoryMenu(CMSAttachMenu): """ Main menu class Handles all types of blog menu """ name = _("Blog menu") _config = {} def get_nodes(self, request): """ Generates the nodelist :param request: :return: list of nodes """ nodes = [] language = get_language_from_request(request, check_path=True) current_site = get_current_site(request) page_site = self.instance.node.site if self.instance and page_site != current_site: return [] categories_menu = False posts_menu = False config = False if self.instance: if not self._config.get(self.instance.application_namespace, False): try: self._config[self.instance.application_namespace] = BlogConfig.objects.get( namespace=self.instance.application_namespace ) except BlogConfig.DoesNotExist as e: logger.exception(e) return [] config = self._config[self.instance.application_namespace] if not getattr(request, "toolbar", False) or not request.toolbar.edit_mode_active: if self.instance == self.instance.get_draft_object(): return [] else: if self.instance == self.instance.get_public_object(): return [] if config and config.menu_structure in (MENU_TYPE_COMPLETE, MENU_TYPE_CATEGORIES): categories_menu = True if config and config.menu_structure in (MENU_TYPE_COMPLETE, MENU_TYPE_POSTS): posts_menu = True if config and config.menu_structure in (MENU_TYPE_NONE,): return nodes used_categories = [] if posts_menu: posts = Post.objects if hasattr(self, "instance") and self.instance: posts = posts.namespace(self.instance.application_namespace).on_site() posts = ( posts.active_translations(language) .distinct() .select_related("app_config") .prefetch_related("translations", "categories") ) for post in posts: post_id = None parent = None used_categories.extend(post.categories.values_list("pk", flat=True)) if categories_menu: category = post.categories.first() if category: parent = "{}-{}".format(category.__class__.__name__, category.pk) post_id = ("{}-{}".format(post.__class__.__name__, post.pk),) else: post_id = ("{}-{}".format(post.__class__.__name__, post.pk),) if post_id: node = NavigationNode(post.get_title(), post.get_absolute_url(language), post_id, parent) nodes.append(node) if categories_menu: categories = BlogCategory.objects if config: categories = categories.namespace(self.instance.application_namespace) if config and not config.menu_empty_categories: categories = categories.active_translations(language).filter(pk__in=used_categories).distinct() else: categories = categories.active_translations(language).distinct() categories = ( categories.order_by("parent__id", "translations__name") .select_related("app_config") .prefetch_related("translations") ) added_categories = [] for category in categories: if category.pk not in added_categories: node = NavigationNode( category.name, category.get_absolute_url(), "{}-{}".format(category.__class__.__name__, category.pk), ("{}-{}".format(category.__class__.__name__, category.parent.id) if category.parent else None), ) nodes.append(node) added_categories.append(category.pk) return nodes class BlogNavModifier(Modifier): """ This navigation modifier makes sure that when a particular blog post is viewed, a corresponding category is selected in menu """ _config = {} def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb): """ Actual modifier function :param request: request :param nodes: complete list of nodes :param namespace: Menu namespace :param root_id: eventual root_id :param post_cut: flag for modifier stage :param breadcrumb: flag for modifier stage :return: nodeslist """ app = None config = None if getattr(request, "current_page", None) and request.current_page.application_urls: app = apphook_pool.get_apphook(request.current_page.application_urls) if app and app.app_config: namespace = resolve(request.path).namespace if not self._config.get(namespace, False): self._config[namespace] = app.get_config(namespace) config = self._config[namespace] try: if config and (not isinstance(config, BlogConfig) or config.menu_structure != MENU_TYPE_CATEGORIES): return nodes except AttributeError: # pragma: no cover # in case `menu_structure` is not present in config return nodes if post_cut: return nodes current_post = getattr(request, get_setting("CURRENT_POST_IDENTIFIER"), None) category = None if current_post and current_post.__class__ == Post: category = current_post.categories.first() if not category: return nodes for node in nodes: if "{}-{}".format(category.__class__.__name__, category.pk) == node.id: node.selected = True return nodes menu_pool.register_modifier(BlogNavModifier) menu_pool.register_menu(BlogCategoryMenu) def clear_menu_cache(**kwargs): """ Empty menu cache when saving categories """ menu_pool.clear(all=True) post_save.connect(clear_menu_cache, sender=BlogCategory) post_delete.connect(clear_menu_cache, sender=BlogCategory) post_delete.connect(clear_menu_cache, sender=BlogConfig)
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,794
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0030_auto_20170509_1831.py
# Generated by Django 1.10.5 on 2017-07-22 05:28 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0029_post_related"), ] operations = [ migrations.AlterField( model_name="posttranslation", name="slug", field=models.SlugField( allow_unicode=True, blank=True, db_index=False, max_length=255, verbose_name="slug" ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,795
fsbraun/djangocms-blog
refs/heads/develop
/tests/base.py
import json import os from copy import deepcopy from app_helper.base_test import BaseTestCase from django.contrib.auth import get_user_model from django.contrib.sites.models import Site from django.core.cache import cache from menus.menu_pool import menu_pool from parler.utils.context import smart_override from djangocms_blog.cms_appconfig import BlogConfig from djangocms_blog.cms_menus import BlogCategoryMenu, BlogNavModifier from djangocms_blog.models import BlogCategory, Post, ThumbnailOption User = get_user_model() def _get_cat_pk(lang, name): return lambda: BlogCategory.objects.language(lang).translated(lang, name=name).get().pk class BaseTest(BaseTestCase): """ Base class with utility function """ category_1 = None thumb_1 = None thumb_2 = None _pages_data = ( { "en": {"title": "page one", "template": "blog.html", "publish": True}, "fr": {"title": "page un", "publish": True}, "it": {"title": "pagina uno", "publish": True}, }, { "en": { "title": "page two", "template": "blog.html", "publish": True, "apphook": "BlogApp", "apphook_namespace": "sample_app", }, "fr": {"title": "page deux", "publish": True}, "it": {"title": "pagina due", "publish": True}, }, { "en": { "title": "page three", "template": "blog.html", "publish": True, "apphook": "BlogApp", "apphook_namespace": "sample_app2", }, "fr": {"title": "page trois", "publish": True}, "it": {"title": "pagina tre", "publish": True}, }, ) _post_data = ( { "en": { "title": "First post", "abstract": "<p>first line</p>", "description": "This is the description", "keywords": "keyword1, keyword2", "text": "Post text", "app_config": "sample_app", "publish": True, }, "it": { "title": "Primo post", "abstract": "<p>prima riga</p>", "description": "Questa è la descrizione", "keywords": "keyword1, keyword2", "text": "Testo del post", }, }, { "en": { "title": "Second post", "abstract": "<p>second post first line</p>", "description": "Second post description", "keywords": "keyword3, keyword4", "text": "Second post text", "app_config": "sample_app", "publish": False, }, "it": { "title": "Secondo post", "abstract": "<p>prima riga del secondo post</p>", "description": "Descrizione del secondo post", "keywords": "keyword3, keyword4", "text": "Testo del secondo post", "app_config": "sample_app", }, }, { "en": { "title": "Third post", "abstract": "<p>third post first line</p>", "description": "third post description", "keywords": "keyword5, keyword6", "text": "Third post text", "app_config": "sample_app", "publish": False, }, "it": { "title": "Terzo post", "abstract": "<p>prima riga del terzo post</p>", "description": "Descrizione del terzo post", "keywords": "keyword5, keyword6", "text": "Testo del terzo post", }, }, { "en": { "title": "Different appconfig", "abstract": "<p>Different appconfig first line</p>", "description": "Different appconfig description", "keywords": "keyword5, keyword6", "text": "Different appconfig text", "app_config": "sample_app2", "publish": True, }, "it": { "title": "Altro appconfig", "abstract": "<p>prima riga del Altro appconfig</p>", "description": "Descrizione Altro appconfig", "keywords": "keyword5, keyword6", "text": "Testo del Altro appconfig", }, }, ) _categories_data = ( {"en": {"name": "Very loud", "app_config": "sample_app"}, "it": {"name": "Fortissimo"}}, {"en": {"name": "Very very silent", "app_config": "sample_app"}, "it": {"name": "Pianississimo"}}, {"en": {"name": "Almost", "app_config": "sample_app"}, "it": {"name": "Mezzo"}}, {"en": {"name": "Drums", "app_config": "sample_app2"}, "it": {"name": "Tamburi"}}, {"en": {"name": "Guitars", "app_config": "sample_app2"}, "it": {"name": "Chitarre"}}, { "en": {"name": "Loud", "parent_id": _get_cat_pk("en", "Almost"), "app_config": "sample_app"}, "it": {"name": "Forte", "parent_id": _get_cat_pk("it", "Mezzo")}, }, {"en": {"name": "Silent", "parent_id": _get_cat_pk("en", "Almost"), "app_config": "sample_app"}}, ) @classmethod def setUpClass(cls): super().setUpClass() cls.thumb_1, __ = ThumbnailOption.objects.get_or_create( name="base", width=100, height=100, crop=True, upscale=False ) cls.thumb_2, __ = ThumbnailOption.objects.get_or_create( name="main", width=200, height=200, crop=False, upscale=False ) cls.app_config_1, __ = BlogConfig.objects.get_or_create(namespace="sample_app") cls.app_config_2, __ = BlogConfig.objects.get_or_create(namespace="sample_app2") cls.app_config_1.app_title = "app1" cls.app_config_1.object_name = "Blog" cls.app_config_1.app_data.config.paginate_by = 1 cls.app_config_1.app_data.config.send_knock_create = True cls.app_config_1.app_data.config.send_knock_update = True cls.app_config_1.save() cls.app_config_2.app_title = "app2" cls.app_config_2.object_name = "Article" cls.app_config_2.app_data.config.paginate_by = 2 cls.app_config_2.app_data.config.send_knock_create = True cls.app_config_2.app_data.config.send_knock_update = True cls.app_config_2.save() cls.app_configs = { "sample_app": cls.app_config_1, "sample_app2": cls.app_config_2, } cls.category_1 = BlogCategory.objects.create(name="category 1", app_config=cls.app_config_1) cls.category_1.set_current_language("it", initialize=True) cls.category_1.name = "categoria 1" cls.category_1.save() cls.site_2, __ = Site.objects.get_or_create(domain="http://example2.com", name="example 2") cls.site_3, __ = Site.objects.get_or_create(domain="http://example3.com", name="example 3") cache.clear() @classmethod def tearDownClass(cls): cache.clear() super().tearDownClass() def tearDown(self): cache.clear() super().tearDown() def get_nodes(self, menu_pool, request): try: nodes = menu_pool.get_renderer(request).get_nodes() except AttributeError: nodes = menu_pool.get_nodes(request) return nodes def _get_category(self, data, category=None, lang="en"): data = deepcopy(data) for k, v in data.items(): if callable(v): data[k] = v() if not category: with smart_override(lang): data["app_config"] = self.app_configs[data["app_config"]] category = BlogCategory.objects.create(**data) else: category.set_current_language(lang, initialize=True) for attr, val in data.items(): setattr(category, attr, val) category.save() return category def _get_post(self, data, post=None, lang="en", sites=None): if not post: post_data = { "author": self.user, "title": data["title"], "abstract": data["abstract"], "meta_description": data["description"], "meta_keywords": data["keywords"], "app_config": self.app_configs[data["app_config"]], } post = Post.objects.create(**post_data) else: post.create_translation( lang, title=data["title"], abstract=data["abstract"], meta_description=data["description"], meta_keywords=data["keywords"], ) post.categories.add(self.category_1) if sites: for site in sites: post.sites.add(site) return post def get_posts(self, sites=None): posts = [] cache.clear() if Post.objects.all().exists(): return list(Post.objects.all()) for post in self._post_data: post1 = self._get_post(post["en"], sites=sites) post1 = self._get_post(post["it"], post=post1, lang="it") post1.publish = post["en"]["publish"] post1.main_image = self.create_filer_image_object() post1.save() posts.append(post1) return posts def get_post_index(self): from haystack import connections from haystack.constants import DEFAULT_ALIAS search_conn = connections[DEFAULT_ALIAS] unified_index = search_conn.get_unified_index() index = unified_index.get_index(Post) return index def _reset_menus(self): cache.clear() BlogCategoryMenu._config = {} BlogNavModifier._config = {} def _reload_menus(self): menu_pool.clear(all=True) menu_pool.discover_menus() # All cms menu modifiers should be removed from menu_pool.modifiers # so that they do not interfere with our menu nodes menu_pool.modifiers = [m for m in menu_pool.modifiers if m.__module__.startswith("djangocms_blog")] self._reset_menus() def read_json(self, path, raw=False): """ Read a json file from the given path :param path: JSON file path (relative to the current test file :type path: str :param raw: return the file content without loading as a json object :type raw: bool :return json data (either raw or loaded) :type: (dict|str) """ full_path = os.path.join(os.path.dirname(__file__), path) with open(full_path) as src: if raw: return src.read() else: return json.load(src)
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,796
fsbraun/djangocms-blog
refs/heads/develop
/tests/test_views.py
import os.path from aldryn_apphooks_config.utils import get_app_instance from app_helper.utils import captured_output from cms.api import add_plugin from cms.toolbar.items import ModalItem from cms.utils.apphook_reload import reload_urlconf from django.contrib.auth.models import AnonymousUser from django.core.exceptions import ImproperlyConfigured from django.core.management import call_command from django.http import Http404 from django.test import override_settings from django.urls import reverse from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ from parler.tests.utils import override_parler_settings from parler.utils.conf import add_default_language_settings from parler.utils.context import smart_override, switch_language from djangocms_blog.feeds import FBInstantArticles, FBInstantFeed, LatestEntriesFeed, TagFeed from djangocms_blog.models import BLOG_CURRENT_NAMESPACE from djangocms_blog.settings import get_setting from djangocms_blog.sitemaps import BlogSitemap from djangocms_blog.views import ( AuthorEntriesView, CategoryEntriesView, PostArchiveView, PostDetailView, PostListView, TaggedListView, ) from .base import BaseTest class CustomUrlViewTest(BaseTest): @override_settings(BLOG_URLCONF="tests.test_utils.blog_urls") def test_post_list_view_custom_urlconf(self): pages = self.get_pages() self.get_posts() self.get_request(pages[1], "en", AnonymousUser()) self.assertEqual(reverse("sample_app:posts-latest"), "/en/page-two/latests/") @override_settings(BLOG_URLCONF="tests.test_utils.blog_urls") def test_check_custom_urlconf(self): """No django check fails with custom urlconf.""" with captured_output() as (out, err): call_command("check", fail_level="DEBUG") self.assertEqual(out.getvalue().strip(), "System check identified no issues (0 silenced).") class ViewTest(BaseTest): def test_check_plain_urlconf(self): """No django check fails with plain urlconf.""" with captured_output() as (out, err): call_command("check", fail_level="DEBUG") self.assertEqual(out.getvalue().strip(), "System check identified no issues (0 silenced).") def test_post_list_view_base_urlconf(self): pages = self.get_pages() self.get_posts() self.get_request(pages[1], "en", AnonymousUser()) self.assertEqual(reverse("sample_app:posts-latest"), "/en/page-two/") def test_post_list_view(self): pages = self.get_pages() posts = self.get_posts() request = self.get_request(pages[1], "en", AnonymousUser()) with smart_override("en"): view_obj = PostListView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) self.assertEqual(getattr(request, BLOG_CURRENT_NAMESPACE, None), None) self.assertEqual(list(view_obj.get_queryset()), [posts[0]]) self.assertEqual(getattr(request, BLOG_CURRENT_NAMESPACE), self.app_config_1) request = self.get_page_request(pages[1], self.user, lang="en", edit=False) view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.request = request view_obj.kwargs = {} qs = view_obj.get_queryset() self.assertEqual(qs.count(), 1) self.assertEqual(set(qs), {posts[0]}) request = self.get_page_request(pages[1], self.user, lang="en", edit=True) view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.request = request self.assertEqual(set(view_obj.get_queryset()), {posts[0], posts[1], posts[2]}) view_obj.kwargs = {} view_obj.args = () view_obj.object_list = view_obj.get_queryset() view_obj.paginate_by = 1 context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertTrue(context["is_paginated"]) self.assertEqual(list(context["post_list"]), [posts[0]]) self.assertEqual(context["paginator"].count, 3) self.assertEqual(context["post_list"][0].title, "First post") response = view_obj.render_to_response(context) self.assertContains(response, context["post_list"][0].get_absolute_url()) self.assertEqual(getattr(request, BLOG_CURRENT_NAMESPACE), self.app_config_1) posts[1].sites.add(self.site_2) self.assertTrue(view_obj.get_queryset().count(), 2) self.assertFalse(posts[1] in view_obj.get_queryset()) with smart_override("it"): request = self.get_page_request(pages[1], self.user, lang="it", edit=True) view_obj = PostListView() view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.request = request view_obj.args = () view_obj.kwargs = {} view_obj.object_list = view_obj.get_queryset() context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertEqual(context["post_list"][0].title, "Primo post") response = view_obj.render_to_response(context) self.assertContains(response, context["post_list"][0].get_absolute_url()) blog_menu = request.toolbar.get_or_create_menu("djangocms_blog", _("Blog")) self.assertEqual(len(blog_menu.items), 5) self.assertEqual( len(blog_menu.find_items(ModalItem, url=reverse("admin:djangocms_blog_post_changelist"))), 1 ) self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse("admin:djangocms_blog_post_add"))), 1) self.assertEqual( len( blog_menu.find_items( ModalItem, url=reverse("admin:djangocms_blog_blogconfig_change", args=(self.app_config_1.pk,)) ) ), 1, ) def test_get_view_url(self): pages = self.get_pages() self.get_posts() # Test the custom version of get_view_url against the different namespaces request = self.get_request(pages[1], "en", AnonymousUser()) view_obj_1 = PostListView() view_obj_1.request = request view_obj_1.args = () view_obj_1.kwargs = {} view_obj_1.namespace, view_obj_1.config = get_app_instance(request) self.assertEqual(view_obj_1.get_view_url(), "http://testserver{}".format(pages[1].get_absolute_url())) request = self.get_request(pages[2], "en", AnonymousUser()) view_obj_2 = PostListView() view_obj_2.request = request view_obj_2.args = () view_obj_2.kwargs = {} view_obj_2.namespace, view_obj_2.config = get_app_instance(request) self.assertEqual(view_obj_2.get_view_url(), "http://testserver{}".format(pages[2].get_absolute_url())) view_obj_2.view_url_name = None with self.assertRaises(ImproperlyConfigured): view_obj_2.get_view_url() def test_post_list_view_fallback(self): pages = self.get_pages() self.get_posts() PARLER_FALLBACK = { # noqa: N806 1: ( {"code": "en"}, {"code": "it"}, {"code": "fr", "hide_untranslated": True}, ), "default": {"fallback": "en", "hide_untranslated": False}, } with smart_override("fr"): view_obj = PostListView() request = self.get_page_request(pages[1], self.user, lang="fr", edit=True) view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.kwargs = {} view_obj.object_list = view_obj.get_queryset() view_obj.get_context_data(object_list=view_obj.object_list) self.assertEqual(view_obj.get_queryset().count(), 3) PARLER_FALLBACK = add_default_language_settings(PARLER_FALLBACK) # noqa: N806 with override_parler_settings(PARLER_LANGUAGES=PARLER_FALLBACK): view_obj = PostListView() request = self.get_page_request(pages[1], self.user, lang="fr", edit=True) view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.kwargs = {} view_obj.object_list = view_obj.get_queryset() view_obj.get_context_data(object_list=view_obj.object_list) self.assertEqual(view_obj.get_queryset().count(), 0) def test_post_detail_view(self): pages = self.get_pages() posts = self.get_posts() with smart_override("en"): with switch_language(posts[0], "en"): request = self.get_page_request(pages[1], AnonymousUser(), lang="en", edit=False) view_obj = PostDetailView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) with self.assertRaises(Http404): view_obj.kwargs = {"slug": "not-existing"} post_obj = view_obj.get_object() view_obj.kwargs = {"slug": posts[0].slug} post_obj = view_obj.get_object() self.assertEqual(post_obj, posts[0]) self.assertEqual(post_obj.language_code, "en") with smart_override("it"): with switch_language(posts[0], "it"): request = self.get_page_request(pages[1], AnonymousUser(), lang="it", edit=False) view_obj = PostDetailView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.kwargs = {"slug": posts[0].slug} post_obj = view_obj.get_object() self.assertEqual(post_obj, posts[0]) self.assertEqual(post_obj.language_code, "it") view_obj.object = post_obj context = view_obj.get_context_data() self.assertEqual(context["post"], posts[0]) self.assertEqual(context["post"].language_code, "it") self.assertTrue(context["meta"]) def test_post_detail_on_different_site(self): pages = self.get_pages() post1 = self._get_post( { "title": "First post", "abstract": "<p>first line</p>", "description": "This is the description", "keywords": "keyword1, keyword2", "app_config": "sample_app", }, sites=(self.site_1,), ) post2 = self._get_post( { "title": "Second post", "abstract": "<p>second post first line</p>", "description": "Second post description", "keywords": "keyword3, keyword4", "app_config": "sample_app", }, sites=(self.site_2,), ) post1.publish = True post1.save() post2.publish = True post2.save() with smart_override("en"): request = self.get_page_request(pages[1], AnonymousUser(), lang="en", edit=False) view_obj = PostDetailView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) with self.assertRaises(Http404): view_obj.kwargs = {"slug": post2.slug} view_obj.get_object() self.assertEqual(view_obj.get_queryset().count(), 1) view_obj.kwargs = {"slug": post1.slug} self.assertTrue(view_obj.get_object()) with self.settings(**{"SITE_ID": self.site_2.pk}): request = self.get_page_request(pages[1], AnonymousUser(), lang="en", edit=False) view_obj = PostDetailView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) with self.assertRaises(Http404): view_obj.kwargs = {"slug": post1.slug} view_obj.get_object() self.assertEqual(view_obj.get_queryset().count(), 1) view_obj.kwargs = {"slug": post2.slug} self.assertTrue(view_obj.get_object()) post1.sites.add(self.site_2) post1.save() view_obj.kwargs = {"slug": post1.slug} self.assertTrue(view_obj.get_object()) self.assertEqual(view_obj.get_queryset().count(), 2) def test_post_archive_view(self): pages = self.get_pages() posts = self.get_posts() with smart_override("en"): request = self.get_page_request(pages[1], AnonymousUser(), lang="en", edit=False) view_obj = PostArchiveView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.kwargs = {"year": now().year, "month": now().month} # One post only, anonymous request qs = view_obj.get_queryset() self.assertEqual(qs.count(), 1) self.assertEqual(list(qs), [posts[0]]) view_obj.object_list = qs context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertEqual( context["archive_date"].date(), now().replace(year=now().year, month=now().month, day=1).date() ) def test_category_entries_view(self): pages = self.get_pages() posts = self.get_posts() with smart_override("en"): request = self.get_page_request(pages[1], self.user, lang="en", edit=True) view_obj = CategoryEntriesView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.kwargs = {"category": "category-1"} qs = view_obj.get_queryset() self.assertEqual(qs.count(), 3) self.assertEqual(set(qs), {posts[0], posts[1], posts[2]}) view_obj.paginate_by = 1 view_obj.object_list = qs context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertTrue(context["category"]) self.assertEqual(context["category"], self.category_1) self.assertTrue(context["is_paginated"]) self.assertEqual(list(context["post_list"]), [posts[0]]) self.assertEqual(context["paginator"].count, 3) self.assertEqual(context["post_list"][0].title, "First post") self.assertTrue(context["meta"]) request = self.get_page_request(pages[1], self.user, edit=False) view_obj.request = request qs = view_obj.get_queryset() self.assertEqual(qs.count(), 1) def test_author_entries_view(self): pages = self.get_pages() posts = self.get_posts() with smart_override("en"): request = self.get_page_request(pages[1], self.user, lang="en", edit=True) view_obj = AuthorEntriesView() view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.request = request view_obj.kwargs = {"username": self.user.get_username()} qs = view_obj.get_queryset() self.assertEqual(qs.count(), 3) self.assertEqual(set(qs), {posts[0], posts[1], posts[2]}) view_obj.paginate_by = 1 view_obj.object_list = qs context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertTrue(context["author"]) self.assertEqual(context["author"], self.user) self.assertTrue(context["is_paginated"]) self.assertEqual(list(context["post_list"]), [posts[0]]) self.assertEqual(context["paginator"].count, 3) self.assertEqual(context["post_list"][0].title, "First post") request = self.get_page_request(pages[1], self.user, edit=False) view_obj.request = request qs = view_obj.get_queryset() self.assertEqual(qs.count(), 1) def test_templates(self): pages = self.get_pages() self.get_posts() with smart_override("en"): request = self.get_page_request(pages[1], self.user, edit=True) view_obj = PostListView() view_obj.request = request view_obj.namespace = self.app_config_1.namespace view_obj.config = self.app_config_1 self.assertEqual(view_obj.get_template_names(), os.path.join("djangocms_blog", "post_list.html")) self.app_config_1.app_data.config.template_prefix = "whatever" self.app_config_1.save() self.assertEqual(view_obj.get_template_names(), os.path.join("whatever", "post_list.html")) self.app_config_1.app_data.config.template_prefix = "" self.app_config_1.save() def test_non_existing_blog_category_should_raise_404(self): pages = self.get_pages() with smart_override("en"): request = self.get_request(pages[1], "en", AnonymousUser()) view_obj = CategoryEntriesView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) with self.assertRaises(Http404): view_obj.kwargs = {"category": "unknown-category"} view_obj.get_queryset() def test_non_existing_author_should_raise_404(self): pages = self.get_pages() with smart_override("en"): request = self.get_request(pages[1], "en", AnonymousUser()) view_obj = AuthorEntriesView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) with self.assertRaises(Http404): view_obj.kwargs = {"username": "unknown-author"} view_obj.get_context_data() class TaggedItemViewTest(BaseTest): def test_taggedlist_view(self): pages = self.get_pages() posts = self.get_posts() posts[0].tags.add("tag 1", "tag 2", "tag 3", "tag 4") posts[0].save() posts[1].tags.add("tag 6", "tag 2", "tag 5", "tag 8") posts[1].save() with smart_override("en"): request = self.get_page_request(pages[1], self.user, lang="en", edit=True) view_obj = TaggedListView() view_obj.request = request view_obj.namespace, view_obj.config = get_app_instance(request) view_obj.kwargs = {"tag": "tag-2"} qs = view_obj.get_queryset() self.assertEqual(qs.count(), 2) self.assertEqual(set(qs), {posts[0], posts[1]}) view_obj.paginate_by = 1 view_obj.object_list = qs context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertTrue(context["tagged_entries"], "tag-2") self.assertTrue(context["is_paginated"]) self.assertEqual(list(context["post_list"]), [posts[0]]) self.assertEqual(context["paginator"].count, 2) self.assertEqual(context["post_list"][0].title, "First post") def test_feed(self): self.user.first_name = "Admin" self.user.last_name = "User" self.user.save() pages = self.get_pages() posts = self.get_posts() posts[0].tags.add("tag 1", "tag 2", "tag 3", "tag 4") posts[0].author = self.user posts[0].save() posts[1].tags.add("tag 6", "tag 2", "tag 5", "tag 8") posts[1].save() posts[0].set_current_language("en") with smart_override("en"): with switch_language(posts[0], "en"): request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url()) feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) self.reload_urlconf() xml = feed(request) self.assertContains(xml, posts[0].get_absolute_url()) self.assertContains(xml, "Blog articles on example.com") self.assertContains(xml, "Admin User</dc:creator>") with smart_override("it"): with switch_language(posts[0], "it"): feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url()) xml = feed(request) self.assertContains(xml, posts[0].get_absolute_url()) self.assertContains(xml, "Articoli del blog su example.com") feed = TagFeed() feed.namespace = self.app_config_1.namespace feed.config = self.app_config_1 self.assertEqual(list(feed.items("tag-2")), [posts[0]]) with smart_override("en"): with switch_language(posts[0], "en"): posts[0].include_in_rss = False posts[0].save() request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url()) feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(len(list(feed.items())), 0) self.reload_urlconf() posts[0].include_in_rss = True posts[0].save() class SitemapViewTest(BaseTest): def test_sitemap(self): self.get_pages() posts = self.get_posts() posts[0].tags.add("tag 1", "tag 2", "tag 3", "tag 4") posts[0].save() posts[1].tags.add("tag 6", "tag 2", "tag 5", "tag 8") posts[1].publish = True posts[1].save() posts[0].set_current_language("en") sitemap = BlogSitemap() self.assertEqual(len(sitemap.items()), 6) for item in sitemap.items(): self.assertEqual(sitemap.lastmod(item).date(), now().date()) self.assertEqual(sitemap.priority(item), get_setting("SITEMAP_PRIORITY_DEFAULT")) self.assertEqual(sitemap.changefreq(item), get_setting("SITEMAP_CHANGEFREQ_DEFAULT")) with smart_override(item.get_current_language()): self.assertEqual(sitemap.location(item), item.get_absolute_url()) def test_sitemap_with_unpublished(self): pages = self.get_pages() self.get_posts() sitemap = BlogSitemap() self.assertEqual(len(sitemap.items()), 4) # unpublish all the pages for page in pages: page.unpublish("en") page.unpublish("it") reload_urlconf() self.assertEqual(len(sitemap.items()), 0) def test_sitemap_config(self): self.get_pages() self.get_posts() self.app_config_1.app_data.config.sitemap_changefreq = "daily" self.app_config_1.app_data.config.sitemap_priority = "0.2" self.app_config_1.save() sitemap = BlogSitemap() self.assertEqual(len(sitemap.items()), 4) for item in sitemap.items(): self.assertEqual(sitemap.lastmod(item).date(), now().date()) if item.app_config == self.app_config_1: self.assertEqual(sitemap.priority(item), "0.2") self.assertEqual(sitemap.changefreq(item), "daily") else: self.assertEqual(sitemap.priority(item), get_setting("SITEMAP_PRIORITY_DEFAULT")) self.assertEqual(sitemap.changefreq(item), get_setting("SITEMAP_CHANGEFREQ_DEFAULT")) self.assertEqual(sitemap.priority(None), get_setting("SITEMAP_PRIORITY_DEFAULT")) self.assertEqual(sitemap.changefreq(None), get_setting("SITEMAP_CHANGEFREQ_DEFAULT")) class InstanctArticlesViewTest(BaseTest): def test_instant_articles(self): self.user.first_name = "Admin" self.user.last_name = "User" self.user.save() pages = self.get_pages() posts = self.get_posts() posts[0].tags.add("tag 1", "tag 2", "tag 3", "tag 4") posts[0].categories.add(self.category_1) posts[0].author = self.user posts[0].save() add_plugin(posts[0].content, "TextPlugin", language="en", body="<h3>Ciao</h3><p></p><p>Ciao</p>") with smart_override("en"): with switch_language(posts[0], "en"): request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url()) feed = FBInstantArticles() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) xml = feed(request) self.assertContains(xml, "<guid>{}</guid>".format(posts[0].guid)) self.assertContains(xml, "content:encoded") self.assertContains( xml, 'class="op-modified" datetime="{}"'.format( posts[0].date_modified.strftime(FBInstantFeed.date_format) ), ) self.assertContains(xml, '<link rel="canonical" href="{}"/>'.format(posts[0].get_full_url())) # Assert text transformation self.assertContains(xml, "<h2>Ciao</h2><p>Ciao</p>") self.assertContains(xml, "<a>Admin User</a>")
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,797
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/fields.py
from django.utils.text import slugify as django_slugify from .settings import get_setting __all__ = ["slugify"] def slugify(base): return django_slugify(base, allow_unicode=get_setting("UNICODE_SLUGS"))
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,798
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0014_auto_20160215_1331.py
from cms.models import Page from cms.utils.i18n import get_language_list from django.db import migrations def forwards(apps, schema_editor): BlogConfig = apps.get_model("djangocms_blog", "BlogConfig") BlogConfigTranslation = apps.get_model("djangocms_blog", "BlogConfigTranslation") Post = apps.get_model("djangocms_blog", "Post") BlogCategory = apps.get_model("djangocms_blog", "BlogCategory") GenericBlogPlugin = apps.get_model("djangocms_blog", "GenericBlogPlugin") LatestPostsPlugin = apps.get_model("djangocms_blog", "LatestPostsPlugin") AuthorEntriesPlugin = apps.get_model("djangocms_blog", "AuthorEntriesPlugin") config = None for page in Page.objects.drafts().filter(application_urls="BlogApp"): config, created = BlogConfig.objects.get_or_create(namespace=page.application_namespace) if not BlogConfigTranslation.objects.exists(): for lang in get_language_list(): title = page.get_title(lang) BlogConfigTranslation.objects.create(language_code=lang, master_id=config.pk, app_title=title) if config: for model in (Post, BlogCategory, GenericBlogPlugin, LatestPostsPlugin, AuthorEntriesPlugin): for item in model.objects.filter(app_config__isnull=True): item.app_config = config item.save() def backwards(apps, schema_editor): # No need for backward data migration pass class Migration(migrations.Migration): dependencies = [ ("cms", "0004_auto_20140924_1038"), ("djangocms_blog", "0013_auto_20160201_2235"), ] operations = [ migrations.RunPython(forwards, backwards), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,799
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0010_auto_20150923_1151.py
import aldryn_apphooks_config.fields import app_data.fields import djangocms_text_ckeditor.fields from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("cms", "0020_old_tree_cleanup"), ("djangocms_blog", "0009_latestpostsplugin_tags_new"), ] operations = [ migrations.CreateModel( name="BlogConfig", fields=[ ("id", models.AutoField(auto_created=True, verbose_name="ID", serialize=False, primary_key=True)), ("type", models.CharField(verbose_name="type", max_length=100)), ( "namespace", models.CharField(default=None, verbose_name="instance namespace", unique=True, max_length=100), ), ("app_data", app_data.fields.AppDataField(editable=False, default="{}")), ], options={ "abstract": False, }, ), migrations.CreateModel( name="BlogConfigTranslation", fields=[ ("id", models.AutoField(auto_created=True, verbose_name="ID", serialize=False, primary_key=True)), ("language_code", models.CharField(db_index=True, verbose_name="Language", max_length=15)), ("app_title", models.CharField(verbose_name="application title", max_length=234)), ( "master", models.ForeignKey( editable=False, to="djangocms_blog.BlogConfig", related_name="translations", null=True, on_delete=models.deletion.CASCADE, ), ), ], options={ "verbose_name": "blog config Translation", "db_table": "djangocms_blog_blogconfig_translation", "default_permissions": (), "db_tablespace": "", "managed": True, }, ), migrations.CreateModel( name="GenericBlogPlugin", fields=[ ( "cmsplugin_ptr", models.OneToOneField( parent_link=True, serialize=False, primary_key=True, auto_created=True, to="cms.CMSPlugin", on_delete=models.deletion.CASCADE, ), ), ( "app_config", aldryn_apphooks_config.fields.AppHookConfigField( verbose_name="app. config", blank=True, to="djangocms_blog.BlogConfig", help_text="When selecting a value, the form is reloaded to get the updated default", ), ), ], options={ "abstract": False, }, bases=("cms.cmsplugin",), ), migrations.AlterField( model_name="posttranslation", name="abstract", field=djangocms_text_ckeditor.fields.HTMLField(default="", verbose_name="abstract", blank=True), ), migrations.AddField( model_name="authorentriesplugin", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( default=None, blank=True, verbose_name="app. config", to="djangocms_blog.BlogConfig", help_text="When selecting a value, the form is reloaded to get the updated default", null=True, ), preserve_default=False, ), migrations.AddField( model_name="blogcategory", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( default=None, verbose_name="app. config", to="djangocms_blog.BlogConfig", help_text="When selecting a value, the form is reloaded to get the updated default", null=True, ), preserve_default=False, ), migrations.AddField( model_name="latestpostsplugin", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( default=None, blank=True, verbose_name="app. config", to="djangocms_blog.BlogConfig", help_text="When selecting a value, the form is reloaded to get the updated default", null=True, ), preserve_default=False, ), migrations.AddField( model_name="post", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( default=None, verbose_name="app. config", to="djangocms_blog.BlogConfig", help_text="When selecting a value, the form is reloaded to get the updated default", null=True, ), preserve_default=False, ), migrations.AlterUniqueTogether( name="blogconfigtranslation", unique_together={("language_code", "master")}, ), migrations.AlterField( model_name="post", name="sites", field=models.ManyToManyField( to="sites.Site", help_text="Select sites in which to show the post. " "If none is set it will be visible in all the configured sites.", blank=True, verbose_name="Site(s)", ), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}
42,287,800
fsbraun/djangocms-blog
refs/heads/develop
/djangocms_blog/migrations/0011_auto_20151024_1809.py
import aldryn_apphooks_config.fields import django.utils.timezone from django.db import migrations, models from djangocms_blog.settings import get_setting class Migration(migrations.Migration): dependencies = [ ("djangocms_blog", "0010_auto_20150923_1151"), ] operations = [ migrations.AddField( model_name="blogconfigtranslation", name="object_name", field=models.CharField( verbose_name="object name", default=get_setting("DEFAULT_OBJECT_NAME"), max_length=234 ), ), migrations.AlterField( model_name="authorentriesplugin", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( blank=True, help_text="When selecting a value, the form is reloaded to get the updated default", to="djangocms_blog.BlogConfig", verbose_name="app. config", null=True, ), ), migrations.AlterField( model_name="blogcategory", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( help_text="When selecting a value, the form is reloaded to get the updated default", to="djangocms_blog.BlogConfig", verbose_name="app. config", null=True, ), ), migrations.AlterField( model_name="genericblogplugin", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( blank=True, help_text="When selecting a value, the form is reloaded to get the updated default", to="djangocms_blog.BlogConfig", verbose_name="app. config", null=True, ), ), migrations.AlterField( model_name="latestpostsplugin", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( blank=True, help_text="When selecting a value, the form is reloaded to get the updated default", to="djangocms_blog.BlogConfig", verbose_name="app. config", null=True, ), ), migrations.AlterField( model_name="post", name="app_config", field=aldryn_apphooks_config.fields.AppHookConfigField( help_text="When selecting a value, the form is reloaded to get the updated default", to="djangocms_blog.BlogConfig", verbose_name="app. config", null=True, ), ), migrations.AlterField( model_name="post", name="date_published", field=models.DateTimeField(verbose_name="published since", default=django.utils.timezone.now), ), migrations.AlterField( model_name="post", name="date_published_end", field=models.DateTimeField(blank=True, verbose_name="published until", null=True), ), ]
{"/djangocms_blog/cms_apps.py": ["/djangocms_blog/models.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/settings.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/cms_appconfig.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/urls_hub.py": ["/djangocms_blog/urls_base.py"], "/djangocms_blog/cms_toolbars.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py"], "/djangocms_blog/utils.py": ["/djangocms_blog/models.py"], "/djangocms_blog/views.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0043_postcontent.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_config.py": ["/djangocms_blog/models.py", "/djangocms_blog/views.py"], "/djangocms_blog/urls_base.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/djangocms_blog/admin.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/utils.py", "/djangocms_blog/cms_appconfig.py"], "/djangocms_blog/migrations/0044_copy_plugins.py": ["/djangocms_blog/models.py"], "/djangocms_blog/templatetags/djangocms_blog.py": ["/djangocms_blog/models.py"], "/djangocms_blog/urls.py": ["/djangocms_blog/urls_base.py"], "/tests/base_test.py": ["/tests/utils.py"], "/tests/test_menu.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/tests/base.py"], "/tests/test_utils/blog_urls.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/settings.py", "/djangocms_blog/views.py"], "/tests/test_utils/urls.py": ["/djangocms_blog/sitemaps/__init__.py"], "/tests/test_liveblog.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/liveblog/models.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/routing.py"], "/tests/test_toolbar.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_extension.py": ["/djangocms_blog/admin.py", "/djangocms_blog/models.py", "/tests/base.py", "/tests/test_utils/admin.py", "/tests/test_utils/models.py"], "/djangocms_blog/forms.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/tests/base.py", "/tests/test_utils/admin.py"], "/djangocms_blog/sitemaps/__init__.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/media_app/models.py": ["/djangocms_blog/media/base.py"], "/tests/test_indexing.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/djangocms_blog/feeds.py": ["/djangocms_blog/settings.py", "/djangocms_blog/views.py", "/djangocms_blog/models.py"], "/djangocms_blog/migrations/0021_auto_20160823_2008.py": ["/djangocms_blog/models.py"], "/djangocms_blog/cms_plugins.py": ["/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0024_auto_20160706_1524.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/cms_wizards.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/forms.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/djangocms_blog/cms_menus.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/base.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/cms_menus.py", "/djangocms_blog/models.py"], "/tests/test_views.py": ["/djangocms_blog/feeds.py", "/djangocms_blog/models.py", "/djangocms_blog/settings.py", "/djangocms_blog/sitemaps/__init__.py", "/djangocms_blog/views.py", "/tests/base.py"], "/djangocms_blog/fields.py": ["/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0011_auto_20151024_1809.py": ["/djangocms_blog/settings.py"], "/tests/media_app/migrations/0001_initial.py": ["/djangocms_blog/media/base.py"], "/djangocms_blog/migrations/0007_auto_20150719_0933.py": ["/djangocms_blog/models.py"], "/tests/test_utils/models.py": ["/djangocms_blog/models.py"], "/tests/test_setup.py": ["/djangocms_blog/cms_appconfig.py", "/tests/base.py"], "/djangocms_blog/migrations/0001_initial.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/cms_plugins.py": ["/djangocms_blog/settings.py", "/djangocms_blog/liveblog/models.py"], "/djangocms_blog/migrations/0018_thumbnail_move2.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/models.py": ["/djangocms_blog/models.py", "/djangocms_blog/settings.py"], "/tests/test_media.py": ["/djangocms_blog/templatetags/djangocms_blog.py", "/tests/base.py"], "/djangocms_blog/migrations/0004_auto_20150108_1435.py": ["/djangocms_blog/models.py"], "/djangocms_blog/models.py": ["/djangocms_blog/cms_appconfig.py", "/djangocms_blog/fields.py", "/djangocms_blog/managers.py", "/djangocms_blog/settings.py"], "/djangocms_blog/migrations/0019_thumbnail_move3.py": ["/djangocms_blog/models.py"], "/djangocms_blog/liveblog/routing.py": ["/djangocms_blog/liveblog/consumers.py"], "/tests/test_wizards.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/test_namespace.py": ["/tests/base.py"], "/tests/test_plugins.py": ["/djangocms_blog/models.py", "/tests/base.py"], "/tests/media_app/cms_plugins.py": ["/tests/media_app/models.py"], "/tests/test_utils/routing.py": ["/djangocms_blog/liveblog/routing.py"], "/djangocms_blog/liveblog/consumers.py": ["/djangocms_blog/models.py"], "/tests/test_utils/admin.py": ["/djangocms_blog/admin.py", "/tests/test_utils/models.py"]}