Skip to content

Commit

Permalink
Delete button for admins. Fix mozillahispano#30
Browse files Browse the repository at this point in the history
Delete button for admins. Fix mozillahispano#30

Added deletion confirmation in delete mention option

I forgot to add delete_mention template

Module not needed removed.

Fixed traslation strings

Delete button for admins. Fix mozillahispano#30

Delete button for admins. Fix mozillahispano#30

Fixed traslation strings in index
  • Loading branch information
Bernardo Botella authored and bbotella committed Nov 5, 2013
1 parent 352286d commit 12eb221
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions mozbuzz/buzz/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ class FollowUpForm(ModelForm):
class Meta:
model = FollowUp
fields = ('status', 'remarks')

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Migration(SchemaMigration):
def forwards(self, orm):

# Adding field 'RSSFeed.product'
db.add_column('buzz_rssfeed', 'product', self.gf('django.db.models.fields.related.ForeignKey')(default=0, related_name='feeds', to=orm['buzz.Product']), keep_default=False)
db.add_column('buzz_rssfeed', 'product', self.gf('django.db.models.fields.related.ForeignKey')(default=1, related_name='feeds', to=orm['buzz.Product']), keep_default=False)


def backwards(self, orm):
Expand Down
31 changes: 31 additions & 0 deletions mozbuzz/buzz/templates/buzz/delete_mention.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends "base.html" %}{% load i18n query %}

{% block main_content %}
<h1>
{%trans "Are you sure?" %}
</h1>
<p>
{%trans "Are you sure you want to delete the mention "%}{{ instance }}{%trans "? All of the following related items will be deleted:"%}
</p>
<form method="post"
{% if pk %}
action="{% url "edit" pk %}"
{% endif %}
id="delete_mention_form">
{% csrf_token %}
{% if not pk and request.GET.rsspost %}
<input type="hidden" name="rsspost_hide" value="{{ request.GET.rsspost }}"/>
{% endif %}
<input type="submit" value="{%trans "Are you sure?" %}" />
</form>
{% endblock %}

{% block extrascript %}
<script src="{{MEDIA_URL}}js/readability.js" type="text/javascript"></script>
<script src="{{MEDIA_URL}}js/to-markdown.js" type="text/javascript"></script>
<script src="{{MEDIA_URL}}js/mozreadability.js" type="text/javascript"></script>
{% if is_new and form.initial.link|length > 10 %}
<script type="text/javascript">guessInformation();</script>
{% endif %}
<script>
{% endblock %}
15 changes: 9 additions & 6 deletions mozbuzz/buzz/templates/buzz/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{%endfor%}
<input type="search" id="id_q" name="q" value="{{query.q}}" placeholder="{% trans "Search by keyword" %}">
</form>
<h2>Mentions</h2>
<h2>{%trans "Mentions" %}</h2>
<ul class="messages segmented mentions">
{% for mention in mentions %}
<li class="message mention">
Expand Down Expand Up @@ -66,19 +66,22 @@ <h3>{%trans "Remarks:"%}</h3>
<p>{{ followup.remarks|markdown }}</p>
</div>
{% endfor %}
<a class="add-followup-inline" href="{% url "followup_new" mention.pk %}">Add followup</a>
<a class="add-followup-inline" href="{% url "followup_new" mention.pk %}">{%trans "Add followup" %}</a>
</div>
<ul class="meta">
<li>Added by {{ mention.creation_user }} on {{ mention.creation_date }}</li>
<li>
{% if mention.followups %}
{{mention.followups|length}} Followups (<a href="#" class="followups-show">show</a>)
{{mention.followups|length}} {%trans "Followups" %} (<a href="#" class="followups-show">{%trans "show" %}</a>)
{% else %}
<a href="{% url "followup_new" mention.pk %}">Add followup</a>
<a href="{% url "followup_new" mention.pk %}">{%trans "Add followup" %}</a>
{% endif %}
</li>
{% if user.is_authenticated %}
<li><a href="{% url "edit" mention.id %}">Edit</a></li>
<li><a href="{% url "edit" mention.id %}">{%trans "Edit" %}</a></li>
{% endif %}
{% if user.is_superuser %}
<li><a href="{% url "delete" mention.id %}">{%trans "Delete" %}</a></li>
{% endif %}
</ul>
</li>
Expand Down Expand Up @@ -158,7 +161,7 @@ <h3>{% trans "Audience" %}</h3>
{% for key,val in query.iteritems %}
<input id="input_audience_{{key}}" type="hidden" name="{{key}}" value="{{val|query_encode_val}}"/>
{%endfor%}
<input id="audience-update" type="submit" style="display:none" value="Update results" />
<input id="audience-update" type="submit" style="display:none" value="{%trans '"Update results"' %} />
</form>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions mozbuzz/buzz/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
url(r'^mention/create$', 'mention', name="create"),
url(r'^mention/(?P<pk>\d+)$', 'mention_view', name="mention_view"),
url(r'^mention/(?P<pk>\d+)/edit$', 'mention', name="edit"),
url(r'^mention/(?P<pk>\d+)/delete$', 'delete_mention', name="delete"),
url(r'^mention/(?P<mention>\d+)/followups/new$', 'followup', name="followup_new"),
url(r'^followup/(?P<pk>\d+)/edit$', 'followup', name="followup_edit"),
url(r'^product/(?P<product>[a-z\-]+)/queue$', 'queue', name="product_queue"),
Expand Down
17 changes: 17 additions & 0 deletions mozbuzz/buzz/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ def mention(request, pk=None):
return {"form": form, "pk": pk, "is_new": is_new}


@login_required
@mozview
def delete_mention(request, pk=None):
if request.method == 'POST':
if pk is None:
return HttpResponseRedirect(reverse(index))
else:
instance = Mention.enabled.get(pk=pk)
instance.delete()
return HttpResponseRedirect(reverse(index))
else:
if pk is None:
return HttpResponseRedirect(reverse(index))
else:
instance = Mention.enabled.get(pk=pk)
return {"instance": instance}

@login_required
@mozview
def followup(request, pk=None, mention=None):
Expand Down

0 comments on commit 12eb221

Please sign in to comment.