aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/forms.py9
-rw-r--r--pyaggr3g470r/static/css/customized-bootstrap.css1
-rw-r--r--pyaggr3g470r/templates/layout.html32
-rw-r--r--pyaggr3g470r/views/feed.py5
-rw-r--r--pyaggr3g470r/views/views.py10
5 files changed, 50 insertions, 7 deletions
diff --git a/pyaggr3g470r/forms.py b/pyaggr3g470r/forms.py
index e385c4e2..fb4a829c 100644
--- a/pyaggr3g470r/forms.py
+++ b/pyaggr3g470r/forms.py
@@ -87,11 +87,16 @@ class SigninForm(Form):
class AddFeedForm(Form):
title = TextField(lazy_gettext("Title"), [validators.Optional()])
- link = TextField(lazy_gettext("Feed link"), [validators.Optional()])
- site_link = TextField(lazy_gettext("Site link"))
+ link = TextField(lazy_gettext("Feed link"))
+ site_link = TextField(lazy_gettext("Site link"), [validators.Optional()])
enabled = BooleanField(lazy_gettext("Check for updates"), default=True)
submit = SubmitField(lazy_gettext("Save"))
+ def validate(self):
+ if not super(AddFeedForm, self).validate():
+ return False
+ return True
+
class ProfileForm(Form):
nickname = TextField(lazy_gettext("Nickname"),
diff --git a/pyaggr3g470r/static/css/customized-bootstrap.css b/pyaggr3g470r/static/css/customized-bootstrap.css
index 58a9d182..1b3c197d 100644
--- a/pyaggr3g470r/static/css/customized-bootstrap.css
+++ b/pyaggr3g470r/static/css/customized-bootstrap.css
@@ -11,7 +11,6 @@ div.top {
.navbar-custom {
background-color: #205081;
border: #205081;
- color: #FFFFFF;
border-radius: 0;
}
diff --git a/pyaggr3g470r/templates/layout.html b/pyaggr3g470r/templates/layout.html
index e673a128..d183f79b 100644
--- a/pyaggr3g470r/templates/layout.html
+++ b/pyaggr3g470r/templates/layout.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+ <!DOCTYPE html>
<html>
<head>
{% block head %}
@@ -33,7 +33,33 @@
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav navbar-right">
{% if g.user.is_authenticated() %}
- <li><a href="{{ url_for("feed.form") }}"><span class="glyphicon glyphicon-plus-sign"></span>{{ _('Add a feed') }}</a></li>
+ <!-- <li><a href="{{ url_for("feed.form") }}"><span class="glyphicon glyphicon-plus-sign"></span> {{ _('Add a feed') }}</a></li> -->
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+ <div><span class="glyphicon glyphicon-plus-sign"></span>&nbsp;{{ _('Add a feed') }}</div>
+ </a>
+ <ul class="dropdown-menu">
+ <li>
+ <form action="/feed/create" class="navbar-form" method="POST" name="save">
+ {{ create_feed_form.hidden_tag() }}
+
+ {{ create_feed_form.link.label }}
+ {{ create_feed_form.link(class_="form-control", placeholder="Feed link") }} {% for error in create_feed_form.link.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
+
+ {{ create_feed_form.title.label }}
+ {{ create_feed_form.title(class_="form-control", placeholder="Optional") }} {% for error in create_feed_form.title.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
+
+ {{ create_feed_form.site_link.label }}
+ {{ create_feed_form.site_link(class_="form-control", placeholder="Optional") }} {% for error in create_feed_form.site_link.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
+
+ {{ create_feed_form.enabled.label }}
+ {{ create_feed_form.enabled(class_="checkbox") }}
+ <br />
+ {{ create_feed_form.submit(class_="btn btn-default") }}
+ </form>
+ </li>
+ </ul>
+ </li>
{% if favorites %}
<li><a href="{{ url_for("home") }}"><span class="glyphicon glyphicon-home"></span> {{ _('Home') }}</a></li>
{% else %}
@@ -78,7 +104,7 @@ i <li><a accesskey="m" href="{{ url_for("management") }}">
</ul>
</li>
{% else %}
- <li><a href="{{ url_for("about") }}"><span class="glyphicon glyphicon-question-sign"></span>{{ _('About') }}</a></li>
+ <li><a href="{{ url_for("about") }}"><span class="glyphicon glyphicon-question-sign"></span>&nbsp;{{ _('About') }}</a></li>
{% endif %}
</ul>
</div><!-- /.navbar-collapse -->
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py
index e4c0dc9a..af43d6f0 100644
--- a/pyaggr3g470r/views/feed.py
+++ b/pyaggr3g470r/views/feed.py
@@ -134,6 +134,8 @@ def form(feed_id=None):
if request.method == 'POST':
if not form.validate():
+ print(dir(form))
+ print("oups")
return render_template('edit_feed.html', form=form)
existing_feeds = list(feed_contr.read(link=form.link.data))
if existing_feeds and feed_id is None:
@@ -141,8 +143,8 @@ def form(feed_id=None):
"warning")
return redirect(url_for('feed.form',
feed_id=existing_feeds[0].id))
-
# Edit an existing feed
+ print("new...")
if feed_id is not None:
feed_contr.update({'id': feed_id},
{'title': form.title.data,
@@ -154,6 +156,7 @@ def form(feed_id=None):
return redirect(url_for('feed.form', feed_id=feed_id))
# Create a new feed
+ print("new feed")
new_feed = FeedController(g.user.id).create(
title=form.title.data,
description="",
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index e06e1a9d..06b234cd 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -138,6 +138,16 @@ def get_timezone():
except:
return conf.TIME_ZONE["en"]
+@app.context_processor
+def inject_feed_form():
+ """
+ Injects the 'AddFeedForm' objects in all templates.
+
+ Context processors run before the template is rendered and have the
+ ability to inject new values into the template context.
+ """
+ return dict(create_feed_form=AddFeedForm())
+
#
# Views.
#
bgstack15