コード例 #1
0
def dir_data_all(pk):
    dir= DirModel.objects.get(pk=pk)
    return {
        'dir':to_dict(dir),
        'parents':[to_dict(p) for p in logic.parents(dir)],
        'child_dirs':[to_dict(child_dir) for child_dir in dir.dirmodel_set.all().order_by('name')],
        'child_files':[to_dict(child_file) for child_file in dir.notemodel_set.all().order_by('name')]
    }
コード例 #2
0
ファイル: tests.py プロジェクト: coblan/first
 def test_dict(self):
     out=[]
     for d in DirModel.objects.all():
         out.append(to_dict(d))
         print(to_dict(d))
     
     
     for j in out:
         print(from_dict(j,DirModel))
コード例 #3
0
    def build(self, request):
        self.ctx.heads = json.dumps(form_to_head(MobilePageForm()))

        id = request.GET.get('page_id')
        if id:
            page = MobilePage.objects.get(pk=id)
            self.ctx.row = json.dumps(to_dict(page))
        else:
            self.ctx.row = json.dumps(to_dict(MobilePage()))
コード例 #4
0
def file_data_all(pk):
    file = NoteModel.objects.get(pk=pk)
    parents=logic.parents(file)
    sibling=logic.get_sibling(file)
    return {'file':to_dict(file),
            'parents':[to_dict(parent) for parent in parents[:-1]],
            'dir':to_dict(parents[-1]),
            'sibling':{'dirs':[to_dict(dir) for dir in sibling[0]],
                       'files':[to_dict(sib) for sib in sibling[1]]}
            }
コード例 #5
0
def search(keywords,user):
    dirs=[]
    for dir in DirModel.objects.filter(name__icontains=keywords,owner=user):
        dirs.append(to_dict(dir))
        
    files=[]
    for file in NoteModel.objects.filter(Q(searchcontent__content__icontains=keywords)|Q(name__icontains=keywords),owner=user):
        files.append(to_dict(file))
    return {'files':files,'dirs':dirs}


        
コード例 #6
0
ファイル: contexts.py プロジェクト: coblan/first
    def build(self):
        super(CtxPage, self).build()
        #self.build_head()
        self.build_comment()

        self.heads = json.dumps(form_to_head(CommentForm()))
        self.row = json.dumps(to_dict(ArtComment(art=self.article)))
コード例 #7
0
ファイル: tables.py プロジェクト: coblan/first
    def get_rows(self):
        query = self.out_filter(self.model.objects.all())
        query = self.inn_filter(query)

        pg = Paginator(query, self.per_page)
        ls = []

        page_nums = get_page_nums(pg.page_range, self.page)
        self.__page_nums = page_nums
        return [to_dict(x) for x in pg.page(self.page)]
コード例 #8
0
def hello(request):
    if request.method == 'GET':
        d, c = DirModel.objects.get_or_create(name='/', owner=request.user)
        #dc = get_files(d.id)
        child_dirs = [to_dict(child_dir) for child_dir in d.dirmodel_set.all()]
        child_files = [
            to_dict(child_file) for child_file in d.notemodel_set.all()
        ]
        #parents=[ajax.parent_dirs(entry)]
        #ps = get_dirParents(d.id)
        dc = {
            'crt_dir': json.dumps(to_dict(d)),  #json.dumps(d.todict()),
            #'ps': child_files, #json.dumps(ps),
            'dirs': json.dumps(child_dirs),  #json.dumps(dc.get('dirs')),
            'files': json.dumps(child_files),  #json.dumps(dc.get('files')),
            #'OTHER_STATIC':settings.OTHER_STATIC
        }
        return render(request, 'share/selfinfo.html', context=dc)
    else:
        return jsonpost(request, ajax.get_globe())
コード例 #9
0
def mobile_page(request, step='page'):

    if request.method == 'GET':
        cls = contexts.get_cls(step)
        if cls:
            return cls().get(request, step)
        else:
            raise Http404('page not found')
        context = {
            'heads': json.dumps(form_to_head(MobilePageForm())),
            'pages': json.dumps([to_dict(x) for x in MobilePage.objects.all()])
        }
        return render(request, 'mbpage.html', context=context)
    else:
        return jsonpost(request, ajax.get_globle())
コード例 #10
0
ファイル: contexts.py プロジェクト: coblan/first
 def build_comment(self):
     self.comments = json.dumps([
         to_dict(comment) for comment in self.article.artcomment_set.all()
     ])
コード例 #11
0
def add_file(name,content,p_dir,user):
    p_dir=from_dict(p_dir) 
    f = NoteModel(name=name,content=content,p_dir=p_dir,owner=user)
    f.save()
    return {'file':to_dict(f)}
コード例 #12
0
def add_mobile_page():
    return to_dict(MobilePage())
コード例 #13
0
def get_page(name):
    try:
        row = PageModel.objects.get(name=name)
        return to_dict(row)
    except PageModel.DoesNotExit:
        return {}