Stanford-only: fix anonymous access with the grade me button

Deny self-service certificates for anonymous users
    
Bugfix for the following condition:
When anonymous (e.g., non-registered) access is enabled for a course, and that course also uses the /request_certificate endpoint (e.g., via the "Grade Me" button), anonymous users could request to be graded and given certificates.
    
As a matter of policy, Stanford doesn't want to give certificates to anonymous students.

This will probably need to be tested on stage before merge.

@jbau plz
So you would prefer that that test be written as
```
from student.models import has_registered
...
if has_registered(request.user):
```
yes?


On Wed, Jun 11, 2014 at 2:47 PM, Jason Bau <notifications@github.com> wrote:

> In lms/djangoapps/certificates/views.py:
>
> > @@ -33,7 +33,7 @@ def request_certificate(request):
> >      then if and only if they pass, do they get a certificate issued.
> >      """
> >      if request.method == "POST":
> > -        if request.user.is_authenticated():
> > +        if request.user.is_authenticated() and request.user.has_registered:
>
> this can be a single classmethod call. Here's the signature in
> common/djangoapps/student/models.py
>
>     @classmethod
>     def has_registered(cls, user):
>         """
>         Handles django anonymous users.  SHOULD use this to test whether request.user has registered,
>         i.e. has a profile that says not nonregistered,
>         instead of directly accessing user.profile.nonregistered,
>         because if the user is AnonymousUser it won't have a profile.
>         """
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/edx/edx-platform/pull/4065/files#r13676231>.
>