#109 Stubbing out the groups page
Merged 8 years ago by ralph. Opened 8 years ago by ralph.

file modified
+27
@@ -17,6 +17,10 @@ 

  

  app = flask.Flask(__name__)

  

+ # Register a global filter, useful for displaying user images

+ app.template_filter('avatar')(hubs.widgets.base.avatar)

+ 

+ 

  logging.basicConfig()

  

  
@@ -70,6 +74,29 @@ 

      return flask.redirect(flask.url_for('hub', name=flask.g.auth.nickname))

  

  

+ @app.route('/groups')

+ def groups():

+     if not flask.g.auth.logged_in:

+         return flask.redirect(flask.url_for('login_fedora'))

+ 

+     # Get the list of promoted and non-promoted group hubs from the DB

+     promoted_names = app.config.get('PROMOTED_GROUPS')

+     groups = hubs.models.Hub.all_group_hubs(session)

+     promoted = [g for g in groups if g.name in promoted_names]

+     secondary = [g for g in groups if g.name not in promoted_names]

+ 

+     name_of_the_month = app.config.get('HUB_OF_THE_MONTH')

+     hub_of_the_month = hubs.models.Hub.by_name(session, name_of_the_month)

+ 

+     return flask.render_template(

+         'groups.html',

+         promoted=promoted,

+         secondary=secondary,

+         hub_of_the_month=hub_of_the_month,

+         session=session,

+     )

+ 

+ 

  @app.route('/<name>')

  @app.route('/<name>/')

  def hub(name):

file modified
+7
@@ -1,1 +1,8 @@ 

  SECRET_KEY = 'changemeforreal'

+ 

+ PROMOTED_GROUPS = [

+     'infra',

+     'i18n',

+ ]

+ 

+ HUB_OF_THE_MONTH = 'commops'

file modified
+8
@@ -209,6 +209,14 @@ 

      get = by_name

  

      @classmethod

+     def all_group_hubs(cls, session):

+         return session.query(cls).filter_by(user_hub=False).all()

+ 

+     @classmethod

+     def all_user_hubs(cls, session):

+         return session.query(cls).filter_by(user_hub=True).all()

+ 

+     @classmethod

      def create_user_hub(cls, session, username, fullname):

          hub = cls(name=username, summary=fullname,

                    avatar=username2avatar(username),

@@ -0,0 +1,121 @@ 

+ <html>

+ <head>

+   <title>Groups</title>

+   <link href="{{ url_for('static', filename='bootstrap/css/bootstrap.css') }}" rel="stylesheet" />

+   <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" />

+   <link href="{{ url_for('static', filename='css/pace-theme-minimal.css') }}" rel="stylesheet" />

+ </head>

+ <script src="{{ url_for('static', filename='js/pace.min.js') }}"></script>

+ <body>

+ <div class="super-header">

+   <div class="row">

+ 	  <div class="col-xs-4" id="logo"><img src="{{ url_for('static', filename='img/logo-hubs.png') }}" alt="Fedora Hubs"></div>

+     <div class="col-sm-4 col-sm-push-4 col-xs-8">

+       {% if g.auth.logged_in %}

+         <div class="dropdown pull-right">

+           <img class = "icon" src="{{ url_for('static', filename='img/irc_icon.png') }}" alt="IRC Chats">

+         <span class="dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">

+           <img src="{{ g.auth.avatar }}" class="avatar" alt="User Icon"/>

+           {# Logged in as #} {{ g.auth.nickname }}

+           <span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span>

+         </span>

+         <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

+           <li class="dropdown-header">Account Information</li>

+           <li><a href="#">Full Name: {{ g.auth.fullname }}</a></li>

+           <li><a href="#">Email: {{ g.auth.email }}</a></li>

+           <li role="separator" class="divider"></li>

+           <li><a href="#">Separated link</a></li>

+         </ul>

+       </div>

+       {% else %}

+         Not logged in.  Click to <a href="{{url_for('login_fedora')}}">login</a>.

+       {% endif %}

+     </div>

+     <div class="col-sm-4 col-sm-pull-4 col-xs-12">

+       <!-- NOT HOOKED UP TO ANYTHING XOXO -->

+       <div class="input-group">

+         <input type="search" placeholder="Search across all hubs ..."></input>

+         <span class="input-group-addon">

+           <span class="glyphicon glyphicon-search"></span>

+         </span>

+     </div>

+     </div>

+   </div>

+ </div>

+ <div class="bookmarks">

+   <nav class="navbar navbar-default">

+     <div class="container-fluid">

+       <div class="navbar-header">

+         <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">

+           <span class="sr-only">Toggle navigation</span>

+           <span class="icon-bar"></span>

+           <span class="icon-bar"></span>

+           <span class="icon-bar"></span>

+         </button>

+       </div>

+ 

+       <!-- Collect the nav links, forms, and other content for toggling -->

+       <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

+         <ul class="nav navbar-nav">

+           {% if g.auth.logged_in %}

+           <li {% if request.path.endswith('/' + g.auth.user.username + '/') %}class='active'{% endif %}>

+             <a href="/{{g.auth.user.username}}">me</a></li>

+           {% for hub in g.auth.user.bookmarks %}

+           <li class='idle-{{hub.activity_class}}{% if request.path.endswith('/' + hub.name + '/') %} active{% endif %}'>

+           <a href="/{{hub.name}}">{{hub.name}}</a></li>

+           {% endfor %}

+           {% endif %}

+         </ul>

+       </div><!-- /.navbar-collapse -->

+     </div><!-- /.container-fluid -->

+   </nav>

+ </div>

+ <div class="header">

+   <div class="img-wrap">

+     <img src="#" />

+   </div>

+   <h3 class="team">Groups</h3>

+ </div>

+ <div class="container">

+   <div class="row">

+   </div>

+   <div class="row">

+     <div class="col-md-12">

+       {% for group in promoted %}

+       {{ group.name }} is a promoted group, and it has {{ group.subscribers | length }} subscribers and {{ group.members | length }} members, and {{group.owners | length }} owners

+       {% endfor %}

+     </div>

+   </div>

+ 

+   <hr/>

+ 

+   <div class="row">

+     <div class="col-md-12">

+       ZOMG - {{ hub_of_the_month.name }} is the Hub Of The Month! <br/>

+       It has {{ hub_of_the_month.subscribers | length }} subscribers and {{ hub_of_the_month.members | length }} members, and {{hub_of_the_month.owners | length }} owners

+       <h6>group owners</h6>

+       {% for owner in hub_of_the_month.owners %}

+           <div class="col-sm-6">

+               <img class="img-circle" src="{{owner.username | avatar}}"/>

+               <a href="{{ url_for('hub', name=owner.username)}}">{{owner.username}}</a>

+           </div>

+       {% endfor %}

+     </div>

+   </div>

+ 

+   <hr/>

+ 

+   <div class="row">

+     <div class="col-md-12">

+       {% for group in secondary %}

+         {{ group.name }} is not a promoted group

+         but it has {{ group.subscribers | length }} subscribers and {{ group.members | length }} members, and {{group.owners | length }} owners

+         <br/>

+       {% endfor %}

+     </div>

+   </div>

+ </div>

+ 

+ <script src="{{ url_for('static', filename='js/jquery-1.10.2.min.js') }}"></script>

+ <script src="{{ url_for('static', filename='bootstrap/js/bootstrap.min.js') }}"></script>

+ </body></html>

@@ -64,6 +64,8 @@ 

            <li class='idle-{{hub.activity_class}}{% if request.path.endswith('/' + hub.name + '/') %} active{% endif %}'>

            <a href="/{{hub.name}}">{{hub.name}}</a></li>

            {% endfor %}

+           <!-- At the end of the list, tack on a link to all groups -->

+           <li><a href="/groups">all</a></li>

            {% endif %}

          </ul>

        </div><!-- /.navbar-collapse -->

no initial comment

@mleonova would like to work on the layout for this.

I checked while running this locally, We need a line break or at least a full-stop over here.

Pull-Request has been updated

8 years ago

Pull-Request has been merged by ralph

8 years ago