Merge branch 'master' into Develop
# Conflicts: # cps/web.py # cps/worker.py
This commit is contained in:
		
						commit
						4ae9d4a749
					
				| 
						 | 
				
			
			@ -65,11 +65,12 @@ $(function() {
 | 
			
		|||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
/*function TableActions (value, row, index) {
 | 
			
		||||
/* Function for deleting domain restrictions */
 | 
			
		||||
function TableActions (value, row, index) {
 | 
			
		||||
    return [
 | 
			
		||||
        "<a class=\"danger remove\" data-toggle=\"modal\" data-target=\"#DeleteDomain\" data-domain-id=\"" + row.id
 | 
			
		||||
        + "\" title=\"Remove\">",
 | 
			
		||||
        "<i class=\"glyphicon glyphicon-trash\"></i>",
 | 
			
		||||
        "</a>"
 | 
			
		||||
    ].join("");
 | 
			
		||||
}*/
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,7 @@
 | 
			
		|||
            </div>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
          {% endif %}
 | 
			
		||||
            {% if g.user.kindle_mail and g.user.is_authenticated and kindle_list %}
 | 
			
		||||
            {% if g.user.kindle_mail and kindle_list %}
 | 
			
		||||
              {% if kindle_list.__len__() == 1 %}
 | 
			
		||||
                <a href="{{url_for('web.send_to_kindle', book_id=entry.id, book_format=kindle_list[0]['format'], convert=kindle_list[0]['convert'])}}" id="sendbtn" data-text="{{_('Send to Kindle')}}" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-send"></span> {{kindle_list[0]['text']}}</a>
 | 
			
		||||
              {% else %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -272,6 +272,7 @@ class Anonymous(AnonymousUserMixin, UserBase):
 | 
			
		|||
        self.locale = data.locale
 | 
			
		||||
        self.mature_content = data.mature_content
 | 
			
		||||
        self.anon_browse = settings.config_anonbrowse
 | 
			
		||||
        self.kindle_mail = data.kindle_mail
 | 
			
		||||
 | 
			
		||||
    def role_admin(self):
 | 
			
		||||
        return False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								cps/web.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								cps/web.py
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -52,6 +52,7 @@ import gdriveutils
 | 
			
		|||
from redirect import redirect_back
 | 
			
		||||
from cps import lm, babel, ub, config, get_locale, language_table, app, db
 | 
			
		||||
from pagination import Pagination
 | 
			
		||||
import unidecode
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
feature_support = dict()
 | 
			
		||||
| 
						 | 
				
			
			@ -873,15 +874,20 @@ def advanced_search():
 | 
			
		|||
        searchterm = " + ".join(filter(None, searchterm))
 | 
			
		||||
        q = q.filter()
 | 
			
		||||
        if author_name:
 | 
			
		||||
            q = q.filter(db.Books.authors.any(db.Authors.name.ilike("%" + author_name + "%")))
 | 
			
		||||
            q = q.filter(db.Books.authors.any(db.or_(db.Authors.name.ilike("%" + author_name + "%"),
 | 
			
		||||
                                                     db.Authors.name.ilike("%" + unidecode.unidecode(author_name)
 | 
			
		||||
                                                                           + "%"))))
 | 
			
		||||
        if book_title:
 | 
			
		||||
            q = q.filter(db.Books.title.ilike("%" + book_title + "%"))
 | 
			
		||||
            q = q.filter(db.or_(db.Books.title.ilike("%" + book_title + "%"),
 | 
			
		||||
                                db.Books.title.ilike("%" + unidecode.unidecode(book_title) + "%")))
 | 
			
		||||
        if pub_start:
 | 
			
		||||
            q = q.filter(db.Books.pubdate >= pub_start)
 | 
			
		||||
        if pub_end:
 | 
			
		||||
            q = q.filter(db.Books.pubdate <= pub_end)
 | 
			
		||||
        if publisher:
 | 
			
		||||
            q = q.filter(db.Books.publishers.any(db.Publishers.name.ilike("%" + publisher + "%")))
 | 
			
		||||
            q = q.filter(db.Books.publishers.any(db.or_(db.Publishers.name.ilike("%" + publisher + "%"),
 | 
			
		||||
                                                        db.Publishers.name.ilike("%" + unidecode.unidecode(publisher)
 | 
			
		||||
                                                                                 + "%"),)))
 | 
			
		||||
        for tag in include_tag_inputs:
 | 
			
		||||
            q = q.filter(db.Books.tags.any(db.Tags.id == tag))
 | 
			
		||||
        for tag in exclude_tag_inputs:
 | 
			
		||||
| 
						 | 
				
			
			@ -904,7 +910,9 @@ def advanced_search():
 | 
			
		|||
            rating_low = int(rating_low) * 2
 | 
			
		||||
            q = q.filter(db.Books.ratings.any(db.Ratings.rating >= rating_low))
 | 
			
		||||
        if description:
 | 
			
		||||
            q = q.filter(db.Books.comments.any(db.Comments.text.ilike("%" + description + "%")))
 | 
			
		||||
            q = q.filter(db.Books.comments.any(db.or_(db.Comments.text.ilike("%" + description + "%"),
 | 
			
		||||
                                                      db.Comments.text.ilike("%" + unidecode.unidecode(description)
 | 
			
		||||
                                                                             + "%"))))
 | 
			
		||||
 | 
			
		||||
        # search custom culumns
 | 
			
		||||
        for c in cc:
 | 
			
		||||
| 
						 | 
				
			
			@ -919,7 +927,8 @@ def advanced_search():
 | 
			
		|||
                        db.cc_classes[c.id].value == custom_query))
 | 
			
		||||
                else:
 | 
			
		||||
                    q = q.filter(getattr(db.Books, 'custom_column_'+str(c.id)).any(
 | 
			
		||||
                        db.cc_classes[c.id].value.ilike("%" + custom_query + "%")))
 | 
			
		||||
                        db.or_(db.cc_classes[c.id].value.ilike("%" + custom_query + "%"),
 | 
			
		||||
                               db.cc_classes[c.id].value.ilike("%" + unidecode.unidecode(custom_query) + "%"))))
 | 
			
		||||
        q = q.all()
 | 
			
		||||
        ids = list()
 | 
			
		||||
        for element in q:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -475,9 +475,9 @@ class WorkerThread(threading.Thread):
 | 
			
		|||
        except (MemoryError) as e:
 | 
			
		||||
            self._handleError(u'Error sending email: ' + e.message)
 | 
			
		||||
            return None
 | 
			
		||||
        except (smtplib.SMTPException) as e:
 | 
			
		||||
        except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e:
 | 
			
		||||
            if hasattr(e, "smtp_error"):
 | 
			
		||||
                text = e.smtp_error.replace("\n",'. ')
 | 
			
		||||
                text = e.smtp_error.decode('utf-8').replace("\n",'. ')
 | 
			
		||||
            elif hasattr(e, "message"):
 | 
			
		||||
                text = e.message
 | 
			
		||||
            else:
 | 
			
		||||
| 
						 | 
				
			
			@ -502,7 +502,6 @@ class WorkerThread(threading.Thread):
 | 
			
		|||
 | 
			
		||||
    def _handleError(self, error_message):
 | 
			
		||||
        app.logger.error(error_message)
 | 
			
		||||
        # self.queue[self.current]['status'] = STAT_FAIL
 | 
			
		||||
        self.UIqueue[self.current]['stat'] = STAT_FAIL
 | 
			
		||||
        self.UIqueue[self.current]['progress'] = "100 %"
 | 
			
		||||
        self.UIqueue[self.current]['runtime'] = self._formatRuntime(
 | 
			
		||||
| 
						 | 
				
			
			@ -510,7 +509,6 @@ class WorkerThread(threading.Thread):
 | 
			
		|||
        self.UIqueue[self.current]['message'] = error_message
 | 
			
		||||
 | 
			
		||||
    def _handleSuccess(self):
 | 
			
		||||
        # self.queue[self.current]['status'] = STAT_FINISH_SUCCESS
 | 
			
		||||
        self.UIqueue[self.current]['stat'] = STAT_FINISH_SUCCESS
 | 
			
		||||
        self.UIqueue[self.current]['progress'] = "100 %"
 | 
			
		||||
        self.UIqueue[self.current]['runtime'] = self._formatRuntime(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user