Skip to content

Commit

Permalink
cleaning up the rest of forum
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhilbert committed Aug 9, 2015
1 parent e6bda23 commit b14ff6e
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 563 deletions.
2 changes: 1 addition & 1 deletion openspending/auth/forum.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def check_perm(user, perm, forum, post_user_id=None):
return True

#need to check the permissions
return post_user_id and user.id and not getattr(user, "is_lockdownuser", False)
return post_user_id == user.id and not getattr(user, "is_lockdownuser", False)
# return True
# #need to figure someting out here
# return user.permissions[perm] and user.id == post_user_id
Expand Down
1 change: 1 addition & 0 deletions openspending/forum/forum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def manage_forum(forum_id, slug=None):
return render_template(
"forum/forum/edit_forum.html", forum=forum_instance, topics=topics,
available_forums=available_forums, forumsread=forumsread,
flaskbb_config=flaskbb_config
)


Expand Down
68 changes: 34 additions & 34 deletions openspending/forum/management/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,45 @@ def overview():
post_count=post_count)


@management.route("/settings", methods=["GET", "POST"])
@management.route("/settings/<path:slug>", methods=["GET", "POST"])
@admin_required
def settings(slug=None):
slug = slug if slug else "general"
# @management.route("/settings", methods=["GET", "POST"])
# @management.route("/settings/<path:slug>", methods=["GET", "POST"])
# @admin_required
# def settings(slug=None):
# slug = slug if slug else "general"

# get the currently active group
active_group = SettingsGroup.query.filter_by(key=slug).first_or_404()
# get all groups - used to build the navigation
all_groups = SettingsGroup.query.all()
# # get the currently active group
# active_group = SettingsGroup.query.filter_by(key=slug).first_or_404()
# # get all groups - used to build the navigation
# all_groups = SettingsGroup.query.all()

SettingsForm = Setting.get_form(active_group)
# SettingsForm = Setting.get_form(active_group)

old_settings = Setting.get_settings(active_group)
new_settings = {}
# old_settings = Setting.get_settings(active_group)
# new_settings = {}

form = SettingsForm()
# form = SettingsForm()

if form.validate_on_submit():
for key, values in iteritems(old_settings):
try:
# check if the value has changed
if values['value'] == form[key].data:
continue
else:
new_settings[key] = form[key].data
except KeyError:
pass
Setting.update(settings=new_settings, app=current_app)
flash(_("Settings saved."), "success")
else:
for key, values in iteritems(old_settings):
try:
form[key].data = values['value']
except (KeyError, ValueError):
pass

return render_template("forum/management/settings.html", form=form,
all_groups=all_groups, active_group=active_group)
# if form.validate_on_submit():
# for key, values in iteritems(old_settings):
# try:
# # check if the value has changed
# if values['value'] == form[key].data:
# continue
# else:
# new_settings[key] = form[key].data
# except KeyError:
# pass
# Setting.update(settings=new_settings, app=current_app)
# flash(_("Settings saved."), "success")
# else:
# for key, values in iteritems(old_settings):
# try:
# form[key].data = values['value']
# except (KeyError, ValueError):
# pass

# return render_template("forum/management/settings.html", form=form,
# all_groups=all_groups, active_group=active_group)


# # Users
Expand Down
2 changes: 1 addition & 1 deletion openspending/forum/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def do_topic_action(topics, user, action, reverse):
For example, to unlock a topic, ``reverse`` should be
set to ``True``.
"""
from openspending.forum.utils.permissions import can_moderate, can_delete_topic
from openspending.auth.forum import can_moderate, can_delete_topic
from openspending.model.account import Account as User
from openspending.forum.forum.models import Post

Expand Down
36 changes: 18 additions & 18 deletions openspending/templates/forum/forum/edit_forum.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% set page_title = forum.title %}
{% set active_forum_nav=True %}

{% extends theme("forum/layout.html") %}
{% extends "forum/layout.html" %}
{% block forumcontent %}
{% from 'macros.html' import render_pagination, topic_pages %}
{% from 'forum/macros.html' import render_pagination, topic_pages %}

<ol class="breadcrumb">
<li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
<li><a href="{{ url_for('forum.index') }}">Forum</a></li>
<li><a href="{{ forum.category.url }}">{{ forum.category.title }}</a></li>
<li class="active">{{ forum.title }}</li>
</ol>
Expand All @@ -29,13 +29,13 @@

<tbody>
<tr>
<td colspan="2">{% trans %}Topic{% endtrans %}</td>
<td colspan="2">Topic</td>

<td>{% trans %}Posts{% endtrans %}</td>
<td>Posts</td>

<td>{% trans %}Views{% endtrans %}</td>
<td>Views</td>

<td>{% trans %}Last Post{% endtrans %}</td>
<td>Last Post</td>

<td><input type="checkbox" name="rowtoggle" class="action-checkall" title="Select All"/></td>
</tr>
Expand Down Expand Up @@ -67,7 +67,7 @@
{{ topic_pages(topic, flaskbb_config["POSTS_PER_PAGE"]) }}
<br />
<small>
{% trans %}by{% endtrans %}
by
{% if topic.user_id %}
<a href="{{ topic.user.url }}">{{ topic.user.username }}</a>
{% else %}
Expand All @@ -86,7 +86,7 @@
<a href="{{ topic.last_post.url }}">{{ topic.last_post.date_created|time_since }}</a><br />

<small>
{% trans %}by{% endtrans %}
by
{% if topic.last_post.user_id %}
<a href="{{ topic.last_post.user.url }}">{{ topic.last_post.user.username }}</a>
{% else %}
Expand All @@ -99,7 +99,7 @@
{% else %}
<tr>
<td colspan="6">
{% trans %}No Topics.{% endtrans %}
No Topics.
</td>
</tr>
{% endfor %}
Expand All @@ -111,7 +111,7 @@
<div class="col-md-2">
<div class="pull-left">
<a class="btn btn-default" href="{{ forum.url }}">
<span class="fa fa-arrow-left"></span> {% trans %}Back{% endtrans %}
<span class="fa fa-arrow-left"></span> Back
</a>
</div>
</div>
Expand All @@ -121,37 +121,37 @@
<div class="form-group">
<div class="btn-group" role="group">
<button name="lock" class="btn btn-warning">
<span class="fa fa-lock"></span> {% trans %}Lock{% endtrans %}
<span class="fa fa-lock"></span> Lock
</button>
<button name="unlock" class="btn btn-warning">
<span class="fa fa-unlock"></span> {% trans %}Unlock{% endtrans %}
<span class="fa fa-unlock"></span> Unlock
</button>
</div>
<div class="btn-group" role="group">
<button name="highlight" class="btn btn-success">
<span class="fa fa-star"></span> {% trans %}Highlight{% endtrans %}
<span class="fa fa-star"></span> Highlight
</button>
<button name="trivialize" class="btn btn-success">
<span class="fa fa-star-o"></span> {% trans %}Trivialize{% endtrans %}
<span class="fa fa-star-o"></span> Trivialize
</button>
</div>

<button name="delete" class="btn btn-danger">
<span class="fa fa-trash-o"></span> {% trans %}Delete{% endtrans %}
<span class="fa fa-trash-o"></span> Delete
</button>
</div>

<div class="form-group row">
<div class="col-sm-5">
<select class="form-control" id="forum" name="forum">
<option selected value="">{% trans %}Move to...{% endtrans %}</option>
<option selected value="">Move to...</option>
{% for forum in available_forums %}
<option value={{forum.id}}>{{ forum.title }}</option>
{% endfor %}
</select>
</div> <!-- end div_class -->
<button name="move" class="btn btn-info">
<span class="fa fa-plane"></span> {% trans %}Move{% endtrans %}
<span class="fa fa-plane"></span> Move
</button>
</div> <!-- end form-group -->
</div>
Expand Down
1 change: 0 additions & 1 deletion openspending/templates/forum/forum/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<tr>
<td colspan="2">
<strong>Board Statistics</strong>
[<a href="{{ url_for('forum.who_is_online') }}" onclick="window.open(this.href, 'wio_window','width=500,height=500'); return false;">Who is online?</a>]
</td>
</tr>
</thead>
Expand Down
19 changes: 0 additions & 19 deletions openspending/templates/forum/forum/online_users.html

This file was deleted.

7 changes: 4 additions & 3 deletions openspending/templates/forum/forum/report_post.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{% set page_title = _("Report Post") %}
{% set page_title = "Report Post" %}

{% extends theme("layout.html") %}
{% extends "forum/layout.html" %}

{% block navigation %}
{% endblock %}

{% block forumcontent %}
{% from theme("macros.html") import render_field %}
{% from "forum/macros.html" import render_field %}

<form class="form" role="form" method="post">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{{ form.hidden_tag() }}
<h3>{% trans %}Report Post{% endtrans %}</h3>

Expand Down
12 changes: 6 additions & 6 deletions openspending/templates/forum/forum/search_form.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{% set page_title = _("Search") %}
{% set page_title = "Search" %}

{% extends theme("layout.html") %}
{% from theme("macros.html") import horizontal_field %}
{% extends "forum/layout.html" %}
{% from "forum/macros.html" import horizontal_field %}
{% block forumcontent %}

<ul class="breadcrumb">
<li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
<li class="active">{% trans %}Search{% endtrans %}</li>
<li><a href="{{ url_for('forum.index') }}">Forum</a></li>
<li class="active">Search</li>
</ul>

<form class="form-horizontal" role="form" method="post">
<h2>{% trans %}Search{% endtrans %}</h2>
<h2>Search</h2>
<hr>
{{ form.hidden_tag() }}
{{ horizontal_field(form.search_types)}}
Expand Down
Loading

0 comments on commit b14ff6e

Please sign in to comment.