Commits

Wilson Xu  committed 95b0923

refactors.

  • Participants
  • Parent commits 674e97d

Comments (0)

Files changed (13)

File fbone/templates/change_password.html

 
 {% extends 'layout.html' %}
 
-{% block main_nav %}{% endblock %}
-{% block search %}{% endblock %}
-{% block learn_more %}{% endblock %}
-
 {% block body %}
 <div class='span12'>
     <form class='form-stacked' method="POST" action="{{ url_for('frontend.change_password') }}">

File fbone/templates/home.html

-{% set page_title = g.user.name %}
-
-{% extends "layout.html" %}
-
-{% block body %}
-{% endblock %}
-

File fbone/templates/login.html

 
 {% extends "layout.html" %}
 
-{% block main_nav %}{% endblock %}
-{% block search %}{% endblock %}
-{% block learn_more %}{% endblock %}
-
 {% block body %}
 <div class='span12'>
     <form class='form-stacked' method="POST" action="{{ url_for('frontend.login') }}">

File fbone/templates/macros/_misc.html

         {% for user in users %}
         <tr>
             <td>{{ loop.index }}</td>
-            <td><a href="{{ url_for('user.show', name=user.name) }}">{{ user.name }}</a></td>
+            <td><a href="{{ url_for('user.pub', name=user.name) }}">{{ user.name }}</a></td>
             <td>{{ user.email }}</td>
         </tr>
         {% endfor %}

File fbone/templates/reauth.html

 
 {% extends "layout.html" %}
 
-{% block main_nav %}{% endblock %}
-{% block search %}{% endblock %}
-{% block learn_more %}{% endblock %}
-
 {% block body %}
 <div class='span12'>
     <form class='form-stacked' method="POST" action="{{ url_for('frontend.reauth') }}">
         {{ form.hidden_tag() }}
         {{ form.next }}
         <fieldset>
-            <legend><b>{{ page_title }}</b>
-            </legend>
+            <legend><b>{{ page_title }}</b></legend>
             {{ render_input(form.password) }}
             {{ render_action(form.submit) }}
         </fieldset>

File fbone/templates/reset_password.html

 
 {% extends 'layout.html' %}
 
-{% block main_nav %}{% endblock %}
-{% block search %}{% endblock %}
-{% block learn_more %}{% endblock %}
-
 {% block body %}
 <div class='span12'>
     <form class='form-stacked' method="POST" action="{{ url_for('frontend.reset_password') }}">
         {{ form.hidden_tag() }}
         {{ form.next }}
         <fieldset>
-            <legend><b>{{ page_title }}</b>
-            </legend>
+            <legend><b>{{ page_title }}</b></legend>
             {{ render_input(form.email) }}
             {{ render_action(form.submit) }}
         </fieldset>

File fbone/templates/signup.html

 
 {% extends 'layout.html' %}
 
-{% block main_nav %}{% endblock %}
-{% block search %}{% endblock %}
-{% block learn_more %}{% endblock %}
-
 {% block body %}
 <div class='span12'>
     <form class='form-stacked' method="POST" action="{{ url_for('frontend.signup') }}">

File fbone/templates/user.html

-{% set page_title = user.name %}
-
-{% extends "layout.html" %}
-
-{% block body %}
-{% endblock %}

File fbone/templates/user_index.html

+{% set page_title = current_user.name %}
+
+{% extends "layout.html" %}
+
+{% block body %}
+{% endblock %}
+

File fbone/templates/user_pub.html

+{% set page_title = user.name %}
+
+{% extends "layout.html" %}
+
+{% block body %}
+{% endblock %}

File fbone/views/frontend.py

 @frontend.route('/')
 def index():
     if current_user.is_authenticated():
-        return redirect(url_for('user.home'))
+        return redirect(url_for('user.index'))
 
     login_form = signup_form = None
     if not current_user.is_authenticated():
             remember = request.form.get('remember') == 'y'
             if login_user(user, remember=remember):
                 flash("Logged in!", 'success')
-            return redirect(form.next.data or url_for('user.home'))
+            return redirect(form.next.data or url_for('user.index'))
         else:
             flash(_('Sorry, invalid login'), 'error')
 
         db.session.commit()
 
         if login_user(user):
-            return redirect(form.next.data or url_for('user.home'))
+            return redirect(form.next.data or url_for('user.index'))
 
     return render_template('signup.html', form=form, login_form=login_form)
 

File fbone/views/user.py

 user = Blueprint('user', __name__, url_prefix='/user')
 
 
-@user.route('/<name>')
-@keep_login_url
-def show(name):
-    if current_user.is_authenticated() and current_user.name == name:
-        return redirect(url_for('user.home'))
-    user = User.query.filter_by(name=name).first_or_404()
-    return render_template('user.html', current_user=current_user)
-
-
 @user.route('/')
 @login_required
-def home():
-    g.user = current_user
-    return render_template('home.html')
+def index():
+    return render_template('user_index.html', current_user=current_user)
+
+
+@user.route('/<name>')
+def pub(name):
+    if current_user.is_authenticated() and current_user.name == name:
+        return redirect(url_for('user.index'))
+
+    user = User.query.filter_by(name=name).first_or_404()
+    return render_template('user_pub.html', user=user)

File tests/test_views.py

         self._make_user()
 
     def test_show(self):
-        self._test_get_request('/user/%s' % self.user.name, 'user.html')
+        self._test_get_request('/user/%s' % self.user.name, 'user_pub.html')
 
         self._login()
         response = self.client.get('/user/%s' % self.user.name)
                              url_quote('/user/', safe=''))
 
         self._login()
-        self._test_get_request('/user/', 'home.html')
+        self._test_get_request('/user/', 'user_index.html')
 
     def test_follow_unfollow(self):
         user1 = User(name='tester1', email='tester1@test.com', password='123456')