This repository was archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 369
Improve notify support #73
Open
falood
wants to merge
2
commits into
pythoncn:master
Choose a base branch
from
falood:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ db.sqlite | |
*.mo | ||
*.log | ||
*.tmp.* | ||
*.swp | ||
*~ | ||
\#.*\# | ||
*.iml | ||
.idea/ | ||
__pycache__ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""create notify table | ||
|
||
Revision ID: 4d51c84f8dca | ||
Revises: 4ad568a7a84e | ||
Create Date: 2014-02-26 13:26:20.556780 | ||
|
||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '4d51c84f8dca' | ||
down_revision = '4ad568a7a84e' | ||
|
||
from datetime import datetime | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'notify', | ||
sa.Column('id', sa.Integer, primary_key=True), | ||
sa.Column('account_id', sa.Integer, nullable=False), | ||
sa.Column('topic_id', sa.Integer, index=True, nullable=False), | ||
sa.Column('reason', sa.String(100), nullable=False), | ||
sa.Column('is_viewed', sa.String(100), default=0, nullable=False), | ||
sa.Column('created', sa.DateTime, default=datetime.utcnow), | ||
) | ||
op.add_column('account', sa.Column('notify_count', sa.Integer, default=0)) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('notify') | ||
op.drop_column('account', 'notify_count') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# coding: utf-8 | ||
|
||
from flask import Blueprint, g, request | ||
from flask import render_template, abort | ||
from ..helpers import force_int | ||
from ..models import Notify | ||
from ..models import fill_with_topics, fill_with_users | ||
from ..utils.user import require_login | ||
|
||
|
||
__all__ = ['bp'] | ||
|
||
bp = Blueprint('notify', __name__) | ||
|
||
|
||
@bp.route('/') | ||
@require_login | ||
def notifies(): | ||
""" | ||
The topics list page. | ||
""" | ||
page = force_int(request.args.get('page', 1), 0) | ||
if not page: | ||
return abort(404) | ||
paginator = Notify.query.filter_by( | ||
account_id=g.user.id, is_viewed=0).order_by( | ||
Notify.created.desc()).paginate(page) | ||
paginator.items = fill_with_users(paginator.items) | ||
paginator.items = fill_with_topics(paginator.items) | ||
return render_template('notify/notify.html', paginator=paginator) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# coding: utf-8 | ||
|
||
from datetime import datetime | ||
from ._base import db, SessionMixin | ||
|
||
__all__ = ['Notify'] | ||
|
||
|
||
class Notify(db.Model, SessionMixin): | ||
id = db.Column(db.Integer, primary_key=True) | ||
account_id = db.Column(db.Integer, nullable=False) | ||
topic_id = db.Column(db.Integer, index=True, nullable=False) | ||
reason = db.Column(db.String(100), nullable=False) | ||
is_viewed = db.Column(db.String(100), default=0, nullable=False) | ||
created = db.Column(db.DateTime, default=datetime.utcnow) | ||
|
||
def __str__(self): | ||
return self.id | ||
|
||
def __repr__(self): | ||
return '<Notify: %s>' % self.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% extends "layout.html" %} | ||
{% from "snippet/macro.html" import notify_columns, pagination %} | ||
|
||
{% block subtitle %}{{ _('Notify') }}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading clearfix"> | ||
<h3 class="panel-title">{{ _('Unread Message') }}</h3> | ||
</div> | ||
<div class="panel-columns"> | ||
{{ notify_columns(paginator.items) }} | ||
</div> | ||
{% if paginator.pages > 1 %} | ||
<div class="panel-footer"> | ||
{{ pagination(paginator, url_for('notify.notifies')) }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is return app at the end of func register_routes necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so why not remove