diff --git a/app/__init__.py b/app/__init__.py index d654229e..68172e37 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -74,6 +74,9 @@ def create_app(config_class=Config): from app.domain import bp as domain_bp app.register_blueprint(domain_bp) + from app.topic import bp as topic_bp + app.register_blueprint(topic_bp) + def get_resource_as_string(name, charset='utf-8'): with app.open_resource(name) as f: return f.read().decode(charset) diff --git a/app/auth/routes.py b/app/auth/routes.py index 5e644f59..6a704c98 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -57,7 +57,10 @@ def login(): db.session.commit() next_page = request.args.get('next') if not next_page or url_parse(next_page).netloc != '': - next_page = url_for('main.index') + if len(current_user.communities()) == 0: + next_page = url_for('topic.choose_topics') + else: + next_page = url_for('main.index') response = make_response(redirect(next_page)) if form.low_bandwidth_mode.data: response.set_cookie('low_bandwidth', '1', expires=datetime(year=2099, month=12, day=30)) @@ -108,9 +111,9 @@ def register(): if current_app.config['MODE'] == 'development': current_app.logger.info('Verify account:' + url_for('auth.verify_email', token=user.verification_token, _external=True)) - flash(_('Great, you are now a registered user! Choose some communities to join. Use the topic filter to narrow things down.')) + flash(_('Great, you are now a registered user!')) - resp = make_response(redirect(url_for('main.list_communities'))) + resp = make_response(redirect(url_for('topic.choose_topics'))) if user_ip_banned(): resp.set_cookie('sesion', '17489047567495', expires=datetime(year=2099, month=12, day=30)) return resp @@ -176,7 +179,10 @@ def verify_email(token): flash(_('Thank you for verifying your email address.')) else: flash(_('Email address validation failed.'), 'error') - return redirect(url_for('main.index')) + if len(user.communities()) == 0: + return redirect(url_for('topic.choose_topics')) + else: + return redirect(url_for('main.index')) @bp.route('/validation_required') diff --git a/app/community/routes.py b/app/community/routes.py index 11db4f75..0cdef2b6 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -315,7 +315,7 @@ def unsubscribe(actor): activity.result = 'success' db.session.commit() if not success: - flash('There was a problem while trying to join', 'error') + flash('There was a problem while trying to unsubscribe', 'error') if proceed: db.session.query(CommunityMember).filter_by(user_id=current_user.id, community_id=community.id).delete() diff --git a/app/models.py b/app/models.py index 7edfe609..838b90e2 100644 --- a/app/models.py +++ b/app/models.py @@ -121,6 +121,7 @@ class File(db.Model): class Topic(db.Model): id = db.Column(db.Integer, primary_key=True) + machine_name = db.Column(db.String(50), index=True) name = db.Column(db.String(50)) num_communities = db.Column(db.Integer, default=0) communities = db.relationship('Community', lazy='dynamic', backref='topic', cascade="all, delete-orphan") @@ -540,7 +541,7 @@ class User(UserMixin, db.Model): def communities(self) -> List[Community]: return Community.query.filter(Community.banned == False).\ - join(CommunityMember).filter(CommunityMember.is_banned == False).all() + join(CommunityMember).filter(CommunityMember.is_banned == False, CommunityMember.user_id == self.id).all() def profile_id(self): return self.ap_profile_id if self.ap_profile_id else f"https://{current_app.config['SERVER_NAME']}/u/{self.user_name}" diff --git a/app/static/structure.css b/app/static/structure.css index 40a47411..bf9be186 100644 --- a/app/static/structure.css +++ b/app/static/structure.css @@ -478,6 +478,16 @@ fieldset legend { content: ">"; } } +.communities_table tbody tr th { + padding: 0; +} +.communities_table tbody tr th a { + padding-top: 10px; + padding-bottom: 10px; + width: 100%; + display: inline-block; +} + .community_header { background-repeat: no-repeat; background-position: center center; @@ -528,6 +538,25 @@ fieldset legend { height: auto; } +#choose_topics_card label.form-control-label { + display: none; +} +#choose_topics_card .form-group { + margin-bottom: 0; +} +#choose_topics_card ul.form-control { + border: none; + list-style-type: none; + padding-top: 0; + margin-bottom: 0; +} +#choose_topics_card ul.form-control li { + vertical-align: center; +} +#choose_topics_card ul.form-control li label { + height: 44px; +} + .form-check .form-check-input { position: relative; top: 4px; diff --git a/app/static/structure.scss b/app/static/structure.scss index 35362563..36b6be8b 100644 --- a/app/static/structure.scss +++ b/app/static/structure.scss @@ -82,6 +82,18 @@ nav, etc which are used site-wide */ } } +.communities_table { + tbody tr th { + padding: 0; + a { + padding-top: 10px; + padding-bottom: 10px; + width: 100%; + display: inline-block; + } + } +} + .community_header { background-repeat: no-repeat; background-position: center center; @@ -133,6 +145,27 @@ nav, etc which are used site-wide */ } } +#choose_topics_card { + label.form-control-label { + display: none; + } + .form-group { + margin-bottom: 0; + } + ul.form-control { + border: none; + list-style-type: none; + padding-top: 0; + margin-bottom: 0; + li { + vertical-align: center; + label { + height: 44px; + } + } + } +} + .form-check .form-check-input { position: relative; top: 4px; diff --git a/app/templates/base.html b/app/templates/base.html index 10e8a637..a1daff11 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -122,10 +122,10 @@