← Back to team overview

openlp-core team mailing list archive

Re: [Merge] lp:~bob-luursema/openlp/bug-1800761 into lp:openlp

 

Review: Needs Fixing

This looks great! One small change that I think you should make (inline in the diff), and then I think we're good to go!

Diff comments:

> 
> === modified file 'openlp/plugins/songs/lib/songselect.py'
> --- openlp/plugins/songs/lib/songselect.py	2019-02-14 15:09:09 +0000
> +++ openlp/plugins/songs/lib/songselect.py	2019-03-05 21:04:35 +0000
> @@ -115,11 +115,31 @@
>              return False
>          if callback:
>              callback()
> +        # Page if user is in an organization
>          if posted_page.find('input', id='SearchText') is not None:
> -            return True
> +            self.subscription_level = self.find_subscription_level(posted_page)
> +            return self.subscription_level
> +        # Page if user is not in an organization
> +        elif posted_page.find('div', id="select-organization") is not None:
> +            try:
> +                home_page = BeautifulSoup(self.opener.open(BASE_URL).read(), 'lxml')
> +            except (TypeError, URLError) as error:
> +                log.exception('Could not reach SongSelect, {error}'.format(error=error))
> +            self.subscription_level = self.find_subscription_level(home_page)
> +            return self.subscription_level
>          else:
>              log.debug(posted_page)
> -            return False
> +            return None
> +    
> +    def find_subscription_level(self, page):
> +        scripts = page.find_all('script')
> +        for tag in scripts:
> +            if tag.string:
> +                match = re.search("'Subscription': '(?P<subscription_level>[^']+)", tag.string)
> +                if match:
> +                    return match.group('subscription_level')
> +        log.error('Could not determine SongSelect subscription level')
> +        return 'unkown'

Maybe just return None?

>  
>      def logout(self):
>          """


-- 
https://code.launchpad.net/~bob-luursema/openlp/bug-1800761/+merge/363996
Your team OpenLP Core is subscribed to branch lp:openlp.


References