diff --git a/securedrop/db.py b/securedrop/db.py index 68bbd4c0c9..ed75ace79c 100644 --- a/securedrop/db.py +++ b/securedrop/db.py @@ -77,6 +77,8 @@ class Source(Base): flagged = Column(Boolean, default=False) last_updated = Column(DateTime, default=datetime.datetime.utcnow) star = relationship("SourceStar", uselist=False, backref="source") + journalist_id = Column(Integer, ForeignKey('journalists.id')) + journalist = relationship("Journalist", backref="assigned") # sources are "pending" and don't get displayed to journalists until they # submit something diff --git a/securedrop/journalist.py b/securedrop/journalist.py index d8daeb0868..155325ad9d 100644 --- a/securedrop/journalist.py +++ b/securedrop/journalist.py @@ -430,8 +430,27 @@ def index(): Submission.query.filter_by(source_id=source.id, downloaded=False).all()) - return render_template('index.html', unstarred=unstarred, starred=starred) + journalists = Journalist.query.order_by(Journalist.username).all() + return render_template('index.html', unstarred=unstarred, starred=starred, journalists=journalists) + +@app.route('/change-assignment/', methods=('POST',)) +@login_required +def change_assignment(sid): + source = get_source(sid) + + if request.form[sid + "-journalist"] == "none": + source.journalist = None + db_session.commit() + return redirect(url_for('index')) + + journalist_query = Journalist.query.filter(Journalist.username == request.form[sid + "-journalist"]) + journalist = get_one_or_else(journalist_query, app.logger, abort) + + source.journalist = journalist + db_session.commit() + + return redirect(url_for('index')) @app.route('/col/') @login_required diff --git a/securedrop/journalist_templates/index.html b/securedrop/journalist_templates/index.html index 0730a66ba4..00577567c5 100644 --- a/securedrop/journalist_templates/index.html +++ b/securedrop/journalist_templates/index.html @@ -34,6 +34,28 @@

Sources

{% endif %} +
+
+

Assigned:

+ {% if source.journalist %} +

{{ source.journalist.username }}

+ {% else %} +

nobody

+ {% endif %} + Reassign +
+
+

Assign new journalist:

+ + + Cancel +
+
{% endfor %} @@ -60,6 +82,28 @@

Sources

{% endif %} +
+
+

Assigned:

+ {% if source.journalist %} +

{{ source.journalist.username }}

+ {% else %} +

nobody

+ {% endif %} + Reassign +
+
+

Assign new journalist:

+ + + Cancel +
+
{% endfor %} diff --git a/securedrop/static/css/journalist.css b/securedrop/static/css/journalist.css index 554a6276bc..f85a3d3457 100644 --- a/securedrop/static/css/journalist.css +++ b/securedrop/static/css/journalist.css @@ -399,6 +399,53 @@ p#codename { #cols li.source:last-child { border-bottom: none; } +#cols li.source .assignment p { + margin: 0; + display: inline-block; +} +#cols li.source .assignment .assign-current { + margin-left: 7%; + font-size: 0.8em; +} +#cols li.source .assignment .assign-current a { + margin-left: 1%; +} +#cols li.source .assignment .btn { + padding: .3%; + width: 10%; + display: inline-block; +} +#cols li.source .assignment button { + margin-left: 3%; + padding: .3%; + width: 10%; +} +#cols li.source .assign-select { + height: 0; + overflow: hidden; +} +#cols li.source .assign-select:target { + height: auto; + overflow: visible; + margin-top: 1%; + text-align: center; +} +#cols li.source .assign-select p { + font-weight: bold; + font-style: italic; +} +#cols li.source .assign-select select { + margin-left: 2%; + width: 23%; +} +#cols li.source .assign-select .btn { + background-color: #999 +} +#cols li.source .assign-select .btn:hover { + color: #999; + background-color: white; +} + #cols li.source .date { float: right; background-color: #999999;