def album_update(request,album_id): """修改相册名""" schools = get_schools(request.user) album = get_object_or_404(Album,id=album_id,site__school__in=schools) if request.method == 'POST': form = AlbumForm(request.POST,instance=album) if form.is_valid(): form.save() messages.success(request, u'已成功修改相册') return redirect(reverse('oa_album_detail',kwargs={'album_id':album.id}))
def album_create(request,site_id): """创建相册""" schools = get_schools(request.user) site = get_object_or_404(WebSite,id=site_id,school__in=schools) if request.method == 'POST': form = AlbumForm(request.POST) if form.is_valid(): category_id = int(request.POST.get('category',0)) category = get_object_or_404(PartCategory,id=category_id) album = form.save(commit=False) album.creator = request.user album.category = category album.site = site album.save() if album.id: messages.success(request, u'已成功创建相册%s ' % album.name) return redirect(reverse('oa_album_school_list',kwargs={'site_id':site.id}) + "?cid=" + str(category_id))