def reply(request, post_id): if request.method == 'POST': f = forms.ForumPostForm(request.POST) if f.is_valid(): root_post = request.post.root_post if not root_post: root_post = request.post post = f.save(commit=False) post.root_post = root_post post.parent_post = request.post root_id = root_post.key().id() post.author_ip=request.META['REMOTE_ADDR'] request.forum.add_post(post) return HttpResponseRedirect('/t/%d/' % root_id) else: f = forms.ForumPostForm() if not request.post.title.startswith('Re: '): f.fields['title'].initial = 'Re: ' + request.post.title else: f.fields['title'].initial = request.post.title p = build_template_params(_('Reply Post'), request.get_full_path(), request.user) p['form'] = f p['forum'] = request.forum return render_to_response(request, 'post/info.html', p)
def group_add(request): if request.method == 'POST': f = forms.UserGroupForm(request.POST) if f.is_valid(): f.save() return HttpResponseRedirect('/admin/group') f = forms.UserGroupForm() p = build_template_params(_('Add Group'), '/', request.user) p['form'] = f return render_to_response(request, 'admin/group/info.html', p)
def category_add(request): if request.method == 'POST': f = forms.ForumCategoryForm(request.POST) if f.is_valid(): f.save() memcache.delete('FORUM_TREE') return HttpResponseRedirect('/admin/category') else: f = forms.ForumCategoryForm() p = build_template_params(_('Add Category'), '/', request.user) p['form'] = f return render_to_response(request, 'admin/category/info.html', p)
def forum_edit(request, forum_id): if request.method == 'POST': f = forms.ForumForm(request.POST, instance = request.forum) if f.is_valid(): f.save() memcache.delete('FORUM_TREE') return HttpResponseRedirect('/admin/forum') else: f = forms.ForumForm(instance = request.forum) p = build_template_params(_('Edit Forum'), '/', request.user) p['form'] = f return render_to_response(request, 'admin/forum/info.html', p)
def games_mine(request): if request.method == 'POST': f = forms.MineGoldConfigForm(request.POST, instance = models.MineGoldConfig.get_instance()) if f.is_valid(): f.save() memcache.delete('GAMES_MINE_GOLD_CONFIG') return HttpResponseRedirect('/admin/') else: f = forms.MineGoldConfigForm(instance = models.MineGoldConfig.get_instance()) p = build_template_params(_("Mine Gold Configuration"), '/', request.user) p['form'] = f return render_to_response(request, 'admin/games/mine/index.html', p)
def club(request): if request.method == 'POST': f = forms.ClubConfigForm(request.POST, instance = models.ClubConfig.get_instance()) if f.is_valid(): f.save() memcache.delete('CLUB_CONFIG') return HttpResponseRedirect('/admin/') else: f = forms.ClubConfigForm(instance = models.ClubConfig.get_instance()) p = build_template_params(_("Club Configuration"), '/', request.user) p['form'] = f return render_to_response(request, 'admin/club.html', p)
def manage_members_add(request, forum_id): if request.method == 'POST': f = forms.UserInGroupForm(request.POST, instance = models.UserInGroup(club_user = request.user, user_group = request.forum.user_group)) if f.is_valid(): user_in_group = f.save(commit=False) request.forum.user_group.add_member(user_in_group.club_user) user_in_group.club_user.add_favourite(request.forum) return HttpResponseRedirect('/f/manage/%d/members' % request.forum.key().id()) f = forms.UserInGroupForm() p = build_template_params('Add Member', '/', request.user) p['forum'] = request.forum p['form'] = f return render_to_response(request, 'forum/manage/members/add.html', p)
def category_edit(request, category_id): category = models.ForumCategory.get_by_id(int(category_id)) if category is not None: if request.method == 'POST': f = forms.ForumCategoryForm(request.POST, instance = category) if f.is_valid(): f.save() memcache.delete('FORUM_TREE') return HttpResponseRedirect('/admin/category') else: f = forms.ForumCategoryForm(instance = category) p = build_template_params(_('Edit Category'), '/', request.user) p['form'] = f return render_to_response(request, 'admin/category/info.html', p) else: raise Http404
def add(request, forum_id): if request.method == "POST": f = forms.ForumPostForm(request.POST) if f.is_valid(): post = f.save(commit=False) post.author_ip=request.META['REMOTE_ADDR'] request.forum.add_post(post) return HttpResponseRedirect("/f/%d/" % request.forum.key().id()) else: f = forms.ForumPostForm() p = build_template_params(_("New Post"), request.get_full_path(), request.user) p['forum'] = request.forum p['form'] = f return render_to_response(request, 'post/info.html', p)
def group_edit(request, group_id): group = models.UserGroup.get_by_id(int(group_id)) if group is None: raise Http404 if request.method == 'POST': f = forms.UserGroupForm(request.POST, instance = group) if f.is_valid(): f.save() return HttpResponseRedirect('/admin/group') else: f = forms.UserGroupForm(instance = group) p = build_template_params(_('Edit Group'), '/', request.user) p['form'] = f return render_to_response(request, 'admin/group/info.html', p)
def index(request, forum_id, first_post_id = None): if first_post_id == '': first_post_id = None pinned = request.forum.get_pinned_threads() posts, next_id = request.forum.get_non_pinned_threads(starting_index = first_post_id, count=20) p = build_template_params(request.forum.name, '/', request.user) p['forum'] = request.forum if next_id is not None: p['next_index'] = next_id p['posts'] = posts p['pinned'] = pinned if (request.user is not None): if (users.is_current_user_admin() or request.forum.is_moderator(request.user)): p['admin_mode'] = True return render_to_response(request, 'forum/index.html', p)
def edit(request, post_id): if request.method == 'POST': f = forms.ForumPostForm(request.POST, instance=request.post) if f.is_valid(): post = f.save() op_record = models.OperationRecord(operator=request.user, target=post, description='EDIT') op_record.put() if post.root_post is not None: forward_post_id = post.root_post.key().id() else: forward_post_id = post.key().id() return HttpResponseRedirect('/t/%d/' % forward_post_id) else: f = forms.ForumPostForm(instance = request.post) p = build_template_params(_('Edit Post'), request.get_full_path(), request.user) p['form'] = f p['forum'] = request.forum return render_to_response(request, 'post/info.html', p)
def index(request): p = build_template_params(_('Account Overview'), '/', request.user) return render_to_response(request, 'services/bank/index.html', p)
def manage_members(request, forum_id): p = build_template_params('Manage Members', '/', request.user) p['forum'] = request.forum return render_to_response(request, 'forum/manage/members/index.html', p)
def forum(request): p = build_template_params(_('Forum Configuration'), '/', request.user) p['categories'] = models.ForumCategory.get_full_forum_tree() return render_to_response(request, 'admin/forum.html', p)
def games(request): p = build_template_params(_('Games Configuration'), '/', request.user) return render_to_response(request, 'admin/games/index.html', p)
def group(request): groups = models.UserGroup.all() p = build_template_params(_('User Groups'), '/', request.user) p['groups'] = groups return render_to_response(request, 'admin/group.html', p)
def manage(request, forum_id): p = build_template_params('Moderate', '/', request.user) p['forum'] = request.forum return render_to_response(request, 'forum/manage/index.html', p)
def index(request): p = build_template_params(_('Admin'), '/', request.user) return render_to_response(request, 'admin/index.html', p)