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

store last dev agreement date on the user when they submit a new addon (bug 695978) #74

Merged
merged 1 commit into from Jun 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/devhub/tests/test_views.py
Expand Up @@ -18,7 +18,6 @@
from pyquery import PyQuery as pq
from tower import strip_whitespace
# Unused, but needed so that we can patch jingo.
from waffle import helpers

import amo
import amo.tests
Expand Down Expand Up @@ -1054,6 +1053,15 @@ def test_step1_submit(self):
"Looks like link %r to %r is still a placeholder" %
(href, ln.text))

def test_read_dev_agreement_set(self):
"""Store current date when the user agrees with the user agreement."""
response = self.client.get(reverse('devhub.submit.1'))
previous = response.context['user'].read_dev_agreement

response = self.client.post(reverse('devhub.submit.1'), follow=True)
user = response.context['user']
assert user.read_dev_agreement != previous


class TestSubmitStep2(amo.tests.TestCase):
# More tests in TestCreateAddon.
Expand Down
5 changes: 2 additions & 3 deletions apps/devhub/views.py
Expand Up @@ -16,6 +16,7 @@
from django.db.models import Count
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.http import urlquote
from django.utils.timezone import now
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt

Expand All @@ -25,11 +26,9 @@
from session_csrf import anonymous_csrf
from tower import ugettext as _
from tower import ugettext_lazy as _lazy
from waffle.decorators import waffle_switch

import amo
import amo.utils
import paypal
from access import acl
from addons import forms as addon_forms
from addons.decorators import addon_view
Expand All @@ -49,7 +48,6 @@
from files.models import File, FileUpload
from files.utils import parse_addon
from search.views import BaseAjaxSearch
from stats.models import Contribution
from translations.models import delete_translation
from users.models import UserProfile
from versions.models import Version
Expand Down Expand Up @@ -1352,6 +1350,7 @@ def _step_url(step):
@submit_step(1)
def submit(request, step):
if request.method == 'POST':
request.user.update(read_dev_agreement=now())
response = redirect(_step_url(2))
response.set_cookie(DEV_AGREEMENT_COOKIE)
return response
Expand Down