Skip to content

Commit

Permalink
Merge pull request #74 from magopian/695978-developer-agreement-date
Browse files Browse the repository at this point in the history
store last dev agreement date on the user when they submit a new addon (bug 695978)
  • Loading branch information
magopian committed Jun 2, 2014
2 parents 2f13876 + bf00609 commit 93bc877
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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 @@ -1354,6 +1352,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

0 comments on commit 93bc877

Please sign in to comment.