diff --git a/assembl/alembic/versions/116f128b0000_locale_as_str.py b/assembl/alembic/versions/116f128b0000_locale_as_str.py index b1eabde6ed..b8d3000fea 100644 --- a/assembl/alembic/versions/116f128b0000_locale_as_str.py +++ b/assembl/alembic/versions/116f128b0000_locale_as_str.py @@ -172,9 +172,16 @@ def downgrade(pyramid_env): 'locale.id', onupdate='CASCADE', ondelete='CASCADE'))) - op.execute('INSERT INTO locale (code, rtl) values ' - + ','.join(["('%s', %s)" % (loc, str(is_rtl(loc)).lower()) - for loc in locales])) + op.execute( + ( + 'INSERT INTO locale (code, rtl) values ' + + ','.join( + "('%s', %s)" % (loc, str(is_rtl(loc)).lower()) + for loc in locales + ) + ) + ) + op.execute('''UPDATE locale_label SET named_locale_id = (SELECT id FROM locale diff --git a/assembl/alembic/versions/1593228f01ab_hopefully_fix_duplicate_imported_.py b/assembl/alembic/versions/1593228f01ab_hopefully_fix_duplicate_imported_.py index 1935d882ba..ead6c8f7b4 100644 --- a/assembl/alembic/versions/1593228f01ab_hopefully_fix_duplicate_imported_.py +++ b/assembl/alembic/versions/1593228f01ab_hopefully_fix_duplicate_imported_.py @@ -66,8 +66,6 @@ def upgrade(pyramid_env): ) """) op.create_unique_constraint(config.get('db_schema')+"_"+config.get('db_user')+"_imported_post_UNQC_source_post_id_source_id", "imported_post", ["source_post_id","source_id"]) - pass - # Do stuff with the app's models here. from assembl import models as m db = m.get_session_maker()() diff --git a/assembl/alembic/versions/1931a5603650_store_mime_type_of_post_body.py b/assembl/alembic/versions/1931a5603650_store_mime_type_of_post_body.py index 8ff661197c..3636e61738 100644 --- a/assembl/alembic/versions/1931a5603650_store_mime_type_of_post_body.py +++ b/assembl/alembic/versions/1931a5603650_store_mime_type_of_post_body.py @@ -25,8 +25,6 @@ def upgrade(pyramid_env): UPDATE imported_post SET body_mime_type = 'text/plain' """) - pass - # Do stuff with the app's models here. from assembl import models as m db = m.get_session_maker()() @@ -38,4 +36,3 @@ def downgrade(pyramid_env): with context.begin_transaction(): #ALTER TABLE assembl..imported_post DROP COLUMN body_mime_type op.drop_column('imported_post', 'body_mime_type') - pass diff --git a/assembl/alembic/versions/27f58fce7b77_override_social_autologin.py b/assembl/alembic/versions/27f58fce7b77_override_social_autologin.py index fd17e7fbb9..f3ea942ac6 100644 --- a/assembl/alembic/versions/27f58fce7b77_override_social_autologin.py +++ b/assembl/alembic/versions/27f58fce7b77_override_social_autologin.py @@ -40,11 +40,13 @@ def upgrade(pyramid_env): if 'default_permissions' in values: found = False for role, permissions in list(values['default_permissions'].items()): - if role not in base_roles: - if P_OVERRIDE_SOCIAL_AUTOLOGIN not in permissions: - permissions.append(P_OVERRIDE_SOCIAL_AUTOLOGIN) - values['default_permissions'][role] = permissions - found = True + if ( + role not in base_roles + and P_OVERRIDE_SOCIAL_AUTOLOGIN not in permissions + ): + permissions.append(P_OVERRIDE_SOCIAL_AUTOLOGIN) + values['default_permissions'][role] = permissions + found = True if found: changes.append({'id': id, 'pref_json': dumps(values)}) if changes: diff --git a/assembl/alembic/versions/30365b67b36d_idea_link_creation.py b/assembl/alembic/versions/30365b67b36d_idea_link_creation.py index 3c53fc1ee0..d199f809cd 100644 --- a/assembl/alembic/versions/30365b67b36d_idea_link_creation.py +++ b/assembl/alembic/versions/30365b67b36d_idea_link_creation.py @@ -52,11 +52,15 @@ def upgrade(pyramid_env): m.IdeaLink.tombstone_date == None).first()[0] <= 1 bases.sort() first = bases[0] - db.execute("""UPDATE idea_idea_link + db.execute( + """UPDATE idea_idea_link SET base_id = %d, creation_date = (SELECT creation_date FROM idea_idea_link AS il2 WHERE base_id=%d LIMIT 1) WHERE base_id IN (%s) - """ % (first, first, ','.join([str(id) for id in bases[1:]]))) + """ + % (first, first, ','.join(str(id) for id in bases[1:])) + ) + mark_changed() diff --git a/assembl/alembic/versions/33c20d131cb6_fix_notification_constraints.py b/assembl/alembic/versions/33c20d131cb6_fix_notification_constraints.py index 4ce8185cbb..fb16eebbf7 100644 --- a/assembl/alembic/versions/33c20d131cb6_fix_notification_constraints.py +++ b/assembl/alembic/versions/33c20d131cb6_fix_notification_constraints.py @@ -23,41 +23,13 @@ def upgrade(pyramid_env): NotificationSubscriptionStatus, NotificationSubscriptionStatus) schema = config.get('db_schema')+"."+config.get('db_user') with context.begin_transaction(): - #No clean way to address constraints, and I didn't find a way to add JUST the constraint from sqlalchemy data structures - constraintNameOld = "ck_"+config.get('db_schema')+"_"+config.get('db_user')+"_notification_subscription_notification_status" - op.execute("""ALTER TABLE notification_subscription DROP CONSTRAINT """+constraintNameOld) - constraintNameNew = "ck_"+config.get('db_schema')+"_"+config.get('db_user')+"_notification_subscription_notification_subscription_status" - op.execute("""ALTER TABLE notification_subscription ADD CONSTRAINT """+constraintNameNew+""" + #No clean way to address constraints, and I didn't find a way to add JUST the constraint from sqlalchemy data structures + constraintNameOld = "ck_"+config.get('db_schema')+"_"+config.get('db_user')+"_notification_subscription_notification_status" + op.execute("""ALTER TABLE notification_subscription DROP CONSTRAINT """+constraintNameOld) + constraintNameNew = "ck_"+config.get('db_schema')+"_"+config.get('db_user')+"_notification_subscription_notification_subscription_status" + op.execute("""ALTER TABLE notification_subscription ADD CONSTRAINT """+constraintNameNew+""" CHECK (status IN ('ACTIVE', 'INACTIVE_DFT', 'UNSUBSCRIBED'))""") - - if False: - """ WOW, no column rename in virtuoso! - For the record, even the following doesn't work (chicken and the egg on null values)! Darn virtuoso""" - op.add_column('notification_subscription', - sa.Column('status_temp', - NotificationSubscriptionStatus.db_type(), - nullable=True, - index = True, - default = NotificationSubscriptionStatus.ACTIVE), - schema=schema) - - op.execute("""UPDATE notification_subscription SET - status_temp = status""") - op.drop_column('notification_subscription', 'status') - op.add_column('notification_subscription', - sa.Column('status', - NotificationSubscriptionStatus.db_type(), - nullable=True, - index = True, - default = NotificationSubscriptionStatus.ACTIVE), - schema=schema) - op.execute("""UPDATE notification_subscription SET - status = status_temp""") - op.execute("""ALTER TABLE notification_subscription - MODIFY status varchar(256) NOT NULL""") - op.drop_column('notification_subscription', 'status_temp') - def downgrade(pyramid_env): with context.begin_transaction(): pass diff --git a/assembl/alembic/versions/368a596ab4b5_tombstone_date.py b/assembl/alembic/versions/368a596ab4b5_tombstone_date.py index 2d193713ea..7c6b422a39 100644 --- a/assembl/alembic/versions/368a596ab4b5_tombstone_date.py +++ b/assembl/alembic/versions/368a596ab4b5_tombstone_date.py @@ -90,7 +90,7 @@ def reconstruct_idea_history(db): if len(live_id): live_id = live_id[0] if live_id else l[-1] non_synth = [id for id in l if id not in synthesis_dates] - if not non_synth[-1] == live_id: + if non_synth[-1] != live_id: import pdb; pdb.set_trace() else: live_id = l[-1] @@ -135,7 +135,7 @@ def reconstruct_vote_history(db): similar_votes.sort(key=lambda v: v.id) previous = None assert not similar_votes[-1].is_tombstone - assert all([vote.is_tombstone for vote in similar_votes[:-1]]) + assert all(vote.is_tombstone for vote in similar_votes[:-1]) live_vote_id = similar_votes[-1].id for vote in similar_votes: vote.base_id = live_vote_id diff --git a/assembl/alembic/versions/4ea8eee4b157_refactor_subject_body_to_content.py b/assembl/alembic/versions/4ea8eee4b157_refactor_subject_body_to_content.py index 1a2d71302b..7fa7888ada 100644 --- a/assembl/alembic/versions/4ea8eee4b157_refactor_subject_body_to_content.py +++ b/assembl/alembic/versions/4ea8eee4b157_refactor_subject_body_to_content.py @@ -44,8 +44,11 @@ def upgrade(pyramid_env): def downgrade(pyramid_env): from assembl.semantic.virtuoso_mapping import get_session from assembl.models import Content - assert not ('body' in Content.__table__.c or 'subject' in Content.__table__.c), \ - "Comment out the body and subject from Content to run the back migration" + assert ( + 'body' not in Content.__table__.c + and 'subject' not in Content.__table__.c + ), "Comment out the body and subject from Content to run the back migration" + dbsession = get_session() try: dbsession.execute("SPARQL drop quad map quadnames:col_pattern_Content_subject") diff --git a/assembl/alembic/versions/525b7451056e_migrate_to_social_auth_account.py b/assembl/alembic/versions/525b7451056e_migrate_to_social_auth_account.py index 0480695759..9ce056dd12 100644 --- a/assembl/alembic/versions/525b7451056e_migrate_to_social_auth_account.py +++ b/assembl/alembic/versions/525b7451056e_migrate_to_social_auth_account.py @@ -109,9 +109,11 @@ def downgrade(pyramid_env): prov_to_dom = { id: old_domains[prov] for (id, prov) in providers.items()} - case_clause = "CASE provider_id %s END" % "\n ".join([ + case_clause = "CASE provider_id %s END" % "\n ".join( "WHEN %d THEN '%s'" % (id, dom) - for (id, dom) in prov_to_dom.items()]) + for (id, dom) in prov_to_dom.items() + ) + db.execute("""INSERT INTO idprovider_agent_account (id, provider_id, username, userid, profile_info, picture_url, domain) diff --git a/assembl/alembic/versions/aad68410c38b_langstring_on_announcements.py b/assembl/alembic/versions/aad68410c38b_langstring_on_announcements.py index 93ecebb712..ad95ef691a 100644 --- a/assembl/alembic/versions/aad68410c38b_langstring_on_announcements.py +++ b/assembl/alembic/versions/aad68410c38b_langstring_on_announcements.py @@ -68,8 +68,7 @@ def upgrade(pyramid_env): lang = candidate_langs[0] def as_lang_string(text): - ls = m.LangString.create(text, lang) - return ls + return m.LangString.create(text, lang) if title: announcement.title = as_lang_string(title) diff --git a/assembl/alembic/versions/ca1c445a2e24_langstring_on_synthesis.py b/assembl/alembic/versions/ca1c445a2e24_langstring_on_synthesis.py index 655a6b1c00..cb03d09efa 100644 --- a/assembl/alembic/versions/ca1c445a2e24_langstring_on_synthesis.py +++ b/assembl/alembic/versions/ca1c445a2e24_langstring_on_synthesis.py @@ -72,8 +72,7 @@ def upgrade(pyramid_env): lang = candidate_langs[0] def as_lang_string(text): - ls = m.LangString.create(text, lang) - return ls + return m.LangString.create(text, lang) if subject: synthesis.subject = as_lang_string(subject) diff --git a/assembl/alembic/versions/f7d61062eccf_multi_extracts.py b/assembl/alembic/versions/f7d61062eccf_multi_extracts.py index 928435997a..afd7bdbfc4 100644 --- a/assembl/alembic/versions/f7d61062eccf_multi_extracts.py +++ b/assembl/alembic/versions/f7d61062eccf_multi_extracts.py @@ -84,7 +84,7 @@ def downgrade(pyramid_env): FROM extract LEFT OUTER JOIN idea_content_link as icl ON (icl.extract_id = extract.id) WHERE icl.id IS NULL - """) + """) connected_extracts = list(db.execute( """SELECT id, extract_id from idea_content_link WHERE extract_id IS NOT NULL""")) @@ -95,16 +95,18 @@ def downgrade(pyramid_env): duplicates = set() for e, icls in by_extract.items(): if len(icls) > 1: - if e in icls: - keep = e - else: - keep = min(*icls) + keep = e if e in icls else min(*icls) dups = set(icls) dups.remove(keep) duplicates.update(dups) if duplicates: - db.execute("DELETE FROM idea_content_link WHERE id IN (%s)" % ( - ",".join([str(x) for x in duplicates]))) + db.execute( + ( + "DELETE FROM idea_content_link WHERE id IN (%s)" + % ",".join(str(x) for x in duplicates) + ) + ) + connected_extracts = [(icl, e) for (icl, e) in connected_extracts if icl not in duplicates] mismatched = [(icl, e) for (icl, e) in connected_extracts if icl != e] diff --git a/assembl/auth/util.py b/assembl/auth/util.py index 9ca5111285..2ad3b941a9 100644 --- a/assembl/auth/util.py +++ b/assembl/auth/util.py @@ -37,10 +37,7 @@ def get_user(request): user = 0 if user is 0: logged_in = request.unauthenticated_userid - if logged_in: - request._user = User.get(logged_in) - else: - request._user = None + request._user = User.get(logged_in) if logged_in else None return request._user @@ -181,10 +178,9 @@ def discussion_id_from_request(request): """Obtain the discussion_id from the request, possibly without fetching the discussion""" from assembl.views.traversal import BaseContext - if request.matchdict: - if 'discussion_id' in request.matchdict: - discussion_id = int(request.matchdict['discussion_id']) - return discussion_id + if request.matchdict and 'discussion_id' in request.matchdict: + discussion_id = int(request.matchdict['discussion_id']) + return discussion_id if getattr(request, "context", None) and isinstance( request.context, BaseContext): discussion_id = request.context.get_discussion_id() @@ -647,7 +643,7 @@ def add_multiple_users_csv( name, email, None, None, True, localrole=with_role, discussion=discussion_id, change_old_password=False) status_in_discussion = None - if send_password_change and not (created_user or created_localrole): + if send_password_change and not created_user and not created_localrole: status_in_discussion = user.get_status_in_discussion(discussion_id) if send_password_change and ( created_user or created_localrole or ( diff --git a/assembl/fabfile.py b/assembl/fabfile.py index 0da8e7c1b8..a5b510f872 100644 --- a/assembl/fabfile.py +++ b/assembl/fabfile.py @@ -685,13 +685,13 @@ def build_virtualenv(): # and that sometimes precludes building python modules. bcfile = "/usr/local/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/distutils.cfg" vefile = env.venvpath + "/lib/python3.6/distutils/distutils.cfg" - sec = "build_ext" if exists(bcfile): brew_config = SafeConfigParser() brew_config.read(bcfile) venv_config = SafeConfigParser() if exists(vefile): venv_config.read(vefile) + sec = "build_ext" if (brew_config.has_section(sec) and not venv_config.has_section(sec)): venv_config.add_section(sec) @@ -955,7 +955,6 @@ def update_node(force_reinstall=False): Install node and npm to a known-good version """ node_version = '12.18.2' - npm_version = '6.14.5' with settings(warn_only=True), hide('running', 'stdout'): node_version_cmd_result = venvcmd("node --version") if force_reinstall or "v"+node_version not in node_version_cmd_result.split(): @@ -963,6 +962,7 @@ def update_node(force_reinstall=False): #Because otherwise node may be busy circus_process_stop('dev:webpack') run("rm -rf "+join(env.venvpath, "lib/node_modules")) + npm_version = '6.14.5' venvcmd(f"nodeenv --node={node_version} --npm={npm_version} --python-virtualenv assembl/static") with cd(get_node_base_path()): venvcmd("npm install --no-save reinstall -g", chdir=False) diff --git a/assembl/lib/sqla.py b/assembl/lib/sqla.py index 56025cfea6..65b9882dda 100644 --- a/assembl/lib/sqla.py +++ b/assembl/lib/sqla.py @@ -107,7 +107,7 @@ def dispose_sqlengines(): db_schema = None _metadata = None Base = None -class_registry = dict() +class_registry = {} aliased_class_registry = None @@ -1583,10 +1583,12 @@ def apply_side_effects_without_json(self, context=None, request=None): collection = sub_i_ctx.__parent__.collection parent_instance = sub_i_ctx.__parent__.parent_instance attr = collection.get_attribute(parent_instance) - if isinstance(attr, list): - if sub_instance not in attr: - collection.on_new_instance(self, sub_instance) - elif attr != sub_instance: + if ( + isinstance(attr, list) + and sub_instance not in attr + or not isinstance(attr, list) + and attr != sub_instance + ): collection.on_new_instance(self, sub_instance) self.db.add(sub_instance) @@ -1651,10 +1653,6 @@ def _do_local_update_from_json( self.__class__.__name__)) setter(self, value) continue - elif parse_instruction[0] == "'": - if value != parse_instruction[1:]: - raise HTTPBadRequest("%s should be %s'" % ( - key, parse_instruction)) else: key = parse_instruction accessor = None diff --git a/assembl/lib/text_search.py b/assembl/lib/text_search.py index 1126458371..dfeaf3e0ba 100644 --- a/assembl/lib/text_search.py +++ b/assembl/lib/text_search.py @@ -131,10 +131,7 @@ def add_simple_text_search(query, text_columns, keywords, include_rank=True): filters = [func.to_tsvector(fts_config, column).match( keywords_j, postgresql_regconfig='simple') for column in text_columns] - if len(filters) > 1: - filter = or_(*filters) - else: - filter = filters[0] + filter = or_(*filters) if len(filters) > 1 else filters[0] query = query.filter(filter) if include_rank: ranks = [func.ts_rank( diff --git a/assembl/models/auth.py b/assembl/models/auth.py index 6366c76a7e..b8bae518e4 100644 --- a/assembl/models/auth.py +++ b/assembl/models/auth.py @@ -191,10 +191,10 @@ def merge(self, other_profile): other_account.merge(my_account) other_account.profile = self session.delete(my_account) - elif (isinstance(other_account, EmailAccount) and - other_account.email.lower() in my_social_emails): - pass - else: + elif ( + not isinstance(other_account, EmailAccount) + or other_account.email.lower() not in my_social_emails + ): other_account.profile = self if other_profile.name and not self.name: self.name = other_profile.name diff --git a/assembl/models/discussion.py b/assembl/models/discussion.py index 2be1fbfdd2..055799bf0a 100644 --- a/assembl/models/discussion.py +++ b/assembl/models/discussion.py @@ -773,12 +773,6 @@ def add_facebook_source_id(inst_ctx, ctx): # post_id = data.get('post_id', None) # fb_post_id = data.get('facebook_post_id', None) raise NotImplementedError("TODO") - post_id = source.sink_post_id - cs = ContentSourceIDs(source=source, - post_id=post_id, - message_id_in_source=fb_post_id) - yield InstanceContext( - inst_ctx['pushed_messages'], cs) return (AllUsersCollection(cls), AllPubFlowsCollection(cls), diff --git a/assembl/models/facebook_integration.py b/assembl/models/facebook_integration.py index 61246b4542..4430af6a67 100644 --- a/assembl/models/facebook_integration.py +++ b/assembl/models/facebook_integration.py @@ -670,7 +670,7 @@ def _create_attachments(self, post, assembl_post, create a Facebook attachment") try: - if not raw_attach or attachment.get('url') == None: + if not raw_attach or attachment.get('url') is None: return old_attachments_on_post = assembl_post.attachments @@ -772,42 +772,39 @@ def _manage_post(self, post, obj_id, posts_db, users_db, upper = self.upper_bound if not lower: lower = self.lower_bound - if upper: - if post_created_time > upper: - cont = False - if lower: - if post_created_time < lower: - cont = False + if upper and post_created_time > upper: + cont = False + if lower and post_created_time < lower: + cont = False - if cont: - post_id = post.get('id') - creator = self.parser.get_user_post_creator(post) - self._manage_user(creator, users_db, reimport) + if not cont: + return None, cont - # Get all of the tagged users instead? - for user in self.parser.get_users_post_to_sans_self(post, obj_id): - self._manage_user(user, users_db, reimport) + post_id = post.get('id') + creator = self.parser.get_user_post_creator(post) + self._manage_user(creator, users_db, reimport) - creator_id = creator.get('id', None) - creator_agent = users_db.get(creator_id) - result = self._create_or_update_post(post, creator_agent, - posts_db, reimport) + # Get all of the tagged users instead? + for user in self.parser.get_users_post_to_sans_self(post, obj_id): + self._manage_user(user, users_db, reimport) - if not result: - return + creator_id = creator.get('id', None) + creator_agent = users_db.get(creator_id) + result = self._create_or_update_post(post, creator_agent, + posts_db, reimport) - assembl_post = posts_db.get(post_id) - self._create_or_update_attachment(post, assembl_post, reimport, - self.parser.get_post_attachments) - # self._create_attachments(post, assembl_post, reimport, - # self.parser.get_post_attachments) - self.db.commit() - # Refresh the instance - self.db.query(self.__class__).populate_existing().get(self.id) - return assembl_post, cont + if not result: + return - else: - return None, cont + assembl_post = posts_db.get(post_id) + self._create_or_update_attachment(post, assembl_post, reimport, + self.parser.get_post_attachments) + # self._create_attachments(post, assembl_post, reimport, + # self.parser.get_post_attachments) + self.db.commit() + # Refresh the instance + self.db.query(self.__class__).populate_existing().get(self.id) + return assembl_post, cont def _manage_comment(self, comment, parent_post, posts_db, users_db, reimport=False): diff --git a/assembl/models/idea.py b/assembl/models/idea.py index ad5c8aafa6..2130423d93 100644 --- a/assembl/models/idea.py +++ b/assembl/models/idea.py @@ -421,10 +421,7 @@ def is_owner(self, user_id): @classmethod def restrict_to_owners_condition(cls, query, user_id, alias=None, alias_maker=None): if not alias: - if alias_maker: - alias = alias_maker.alias_from_class(cls) - else: - alias = cls + alias = alias_maker.alias_from_class(cls) if alias_maker else cls return (query, alias.creator_id == user_id) @classmethod @@ -804,10 +801,7 @@ def _visit_ideas_breadth_first( return idea_visitor.end_visit(self, level, prev_result, child_results) def most_common_words(self, lang=None, num=8): - if lang: - langs = (lang,) - else: - langs = self.discussion.discussion_locales + langs = (lang, ) if lang else self.discussion.discussion_locales word_counter = WordCountVisitor(langs) self.visit_ideas_depth_first(word_counter) return word_counter.best(num) @@ -1304,8 +1298,7 @@ def add_related_post_link(inst_ctx, ctx): inst_ctx=WidgetPost, ctx='Idea.linkedposts') def add_youtube_attachment(inst_ctx, ctx): from .attachment import Document, PostAttachment - for subctx in add_related_post_link(inst_ctx, ctx): - yield subctx + yield from add_related_post_link(inst_ctx, ctx) post = inst_ctx._instance insp_url = post.metadata_json.get('inspiration_url', '') if insp_url.startswith("https://www.youtube.com/"): diff --git a/assembl/models/idea_graph_view.py b/assembl/models/idea_graph_view.py index 1cbd50e85b..b7254cb7a0 100644 --- a/assembl/models/idea_graph_view.py +++ b/assembl/models/idea_graph_view.py @@ -259,9 +259,8 @@ class ExplicitSubGraphView(IdeaGraphView): } def copy(self, db=None): - retval = IdeaGraphView.copy(self, db=db) # retval.ideas = self.ideas - return retval + return IdeaGraphView.copy(self, db=db) def get_idea_links(self): # more efficient than the association_proxy diff --git a/assembl/models/idea_source.py b/assembl/models/idea_source.py index 3cf47bb9b0..0ae60b1ef6 100644 --- a/assembl/models/idea_source.py +++ b/assembl/models/idea_source.py @@ -200,15 +200,13 @@ def read_json(self, data, admin_user_id, apply_filter=False): def find_objects(j): if isinstance(j, list): for x in j: - for obj in find_objects(x): - yield obj + yield from find_objects(x) elif isinstance(j, dict): jid = j.get('@id', None) if jid: yield j for x in j.values(): - for obj in find_objects(x): - yield obj + yield from find_objects(x) self.read_data_gen(find_objects(data), admin_user_id, apply_filter) @@ -383,15 +381,13 @@ def read_data(self, jsonld, admin_user_id, base=None): def find_objects(j): if isinstance(j, list): for x in j: - for obj in find_objects(x): - yield obj + yield from find_objects(x) elif isinstance(j, dict): jid = j.get('@id', None) if jid: yield j for x in j.values(): - for obj in find_objects(x): - yield obj + yield from find_objects(x) self.read_data_gen(find_objects(jsonld), admin_user_id) self.db.flush() diff --git a/assembl/models/mail.py b/assembl/models/mail.py index ae08eb9f8e..c20c63600f 100644 --- a/assembl/models/mail.py +++ b/assembl/models/mail.py @@ -391,9 +391,8 @@ def extract_text(part): if len(parts) == 1: return (parts[0], parts_type) if parts_type == "text/html": - return ("\n".join([ - "