#218 Allow configuring the number of meeting shown in the meetings widget
Merged 7 years ago by pingou. Opened 7 years ago by pingou.
pingou/fedora-hubs n_meetings  into  develop

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

              error = True

              break

          try:

-             arg.validator(session, val)

+             val = arg.validator(session, val)

              config[arg.name] = val

          except Exception as err:

              flask.flash('Invalid data provided, error: %s' % err, 'error')

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

  

  

  def required(session, value):

-     return bool(value)

+     if bool(value):

+         return value

  

  

  def text(session, value):

file modified
+12 -3
@@ -54,7 +54,7 @@ 

  

  

  footer_template = templating.environment.get_template('templates/meeting_footer.html')

- chrome = panel(title = 'Meetings', key='meetings', footer_template=footer_template)

+ chrome = panel(title='Meetings', footer_template=footer_template)

  templating.environment.filters['humanize'] = lambda d: arrow.get(d).humanize()

  template = templating.environment.get_template('templates/meetings.html')

  position = 'both'
@@ -64,7 +64,11 @@ 

            default=None,

            validator=validators.required,

            help="A fedocal calendar.")

- def data(session, widget, calendar):

+ @argument(name="n_meetings",

+           default=4,

+           validator=validators.integer,

+           help="The number of meetings to display.")

+ def data(session, widget, calendar, n_meetings=4):

      base = 'https://apps.fedoraproject.org/calendar/api/meetings/?calendar=%s'

      url = base % calendar

      response = requests.get(url).json()
@@ -82,8 +86,13 @@ 

          if not selected:

              continue

          meetings[title] = selected

+         if len(meetings) >= n_meetings:

+             break

  

-     return dict(meetings=meetings)

+     return dict(

+         calendar=calendar,

+         meetings=meetings,

+     )

  

  

  @hint(ubiquitous=True)

@@ -1,4 +1,3 @@ 

- {% if meetings %}

  {% for title, next in meetings.items() %}

  <div class="meeting">

    <div class="row">
@@ -40,5 +39,10 @@ 

    {% endif  %}

  </div>

  {% if meetings | length > 1 %} <hr> {% endif %}

+ {% else %}

+ <div class="meeting">

+   <div class="row">

+     No coming meetings in {{ calendar }}.

+   </div>

+ </div>

  {% endfor %}

- {% endif %}

no initial comment

Won't the integer validator return this value?

I thought but from testing it seems not :(

Confirmed it works locally. LGTM :thumbsup:

Ok I found the right way to do this (w/ the validators working as expected and all)

2 new commits added

  • Always display the meetings widget, even if there are no coming meetings
  • Let the validator return the validated value and use it when editing a widget
7 years ago

rebased

7 years ago

Rebased and updated :)

:thumbsup: just needs another rebase :) HEAD is moving fast

rebased

7 years ago

Pull-Request has been merged by pingou

7 years ago