Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added source-assignment functionality #1359

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions securedrop/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion securedrop/journalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<sid>', 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/<sid>')
@login_required
Expand Down
44 changes: 44 additions & 0 deletions securedrop/journalist_templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ <h2><span class="headline">Sources</span></h2>
</span>
{% endif %}
</div>
<div id="{{ source.filesystem_id }}-assignment" class="assignment">
<div class="assign-current">
<p>Assigned:</p>
{% if source.journalist %}
<p>{{ source.journalist.username }}</p>
{% else %}
<p>nobody</p>
{% endif %}
<a href="#{{ source.filesystem_id }}-reassign">Reassign</a>
</div>
<div id="{{ source.filesystem_id }}-reassign" class="assign-select">
<p>Assign new journalist:</p>
<select name="{{ source.filesystem_id }}-journalist">
<option value="none">nobody</option>
{% for journalist in journalists %}
<option value="{{ journalist.username }}">{{ journalist.username }}</option>
{% endfor %}
</select>
<button formaction="/change-assignment/{{ source.filesystem_id }}">Apply</button>
<a class="btn" href="#{{ source.filesystem_id }}-assignment">Cancel</a>
</div>
</div>
</li>
{% endfor %}
</ul>
Expand All @@ -60,6 +82,28 @@ <h2><span class="headline">Sources</span></h2>
</span>
{% endif %}
</div>
<div id="{{ source.filesystem_id }}-assignment" class="assignment">
<div class="assign-current">
<p>Assigned:</p>
{% if source.journalist %}
<p>{{ source.journalist.username }}</p>
{% else %}
<p>nobody</p>
{% endif %}
<a href="#{{ source.filesystem_id }}-reassign">Reassign</a>
</div>
<div id="{{ source.filesystem_id }}-reassign" class="assign-select">
<p>Assign new journalist:</p>
<select name="{{ source.filesystem_id }}-journalist">
<option value="none">nobody</option>
{% for journalist in journalists %}
<option value="{{ journalist.username }}">{{ journalist.username }}</option>
{% endfor %}
</select>
<button formaction="/change-assignment/{{ source.filesystem_id }}">Apply</button>
<a class="btn" href="#{{ source.filesystem_id }}-assignment">Cancel</a>
</div>
</div>
</li>
{% endfor %}
</ul>
Expand Down
47 changes: 47 additions & 0 deletions securedrop/static/css/journalist.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down