Beispiel #1
0
def register(request,
             success_url=None,
             form_class=RegistrationForm,
             profile_callback=None,
             template_name='registration/registration_form.html',
             extra_context=None):
    if 'INVITE_MODE' in settings.get_all_members() and settings.INVITE_MODE:
        if 'invitation_key' in request.REQUEST \
            and is_key_valid(request.REQUEST['invitation_key']):
            if extra_context is None:
                extra_context = {
                    'invitation_key': request.REQUEST['invitation_key']
                }
            else:
                extra_context.update({'invitation_key': invitation_key})
            return registration_register(request, success_url, form_class,
                                         profile_callback, template_name,
                                         extra_context)
        else:
            return direct_to_template(request,
                                      'invitation/wrong_invitation_key.html')
    else:
        return registration_register(request, success_url, form_class,
                                     profile_callback, template_name,
                                     extra_context)
def invite(request, success_url=None, form_class=InvitationForm,
           template_name='invitation/invitation_form.html',):
    context = {}
    if 'INVITATIONS_PER_USER' in settings.get_all_members():
        remaining_invitations = Invitation.objects.remaining_invitations_for_user(request.user)
        if not remaining_invitations:
            error_msg = _("You do not have any remaining invitations.")
            return render(request, 'invitation/invalid.html', {'error_msg': error_msg})
        else:
            context['remaining_invitations'] = remaining_invitations

    if request.method == 'POST':
        form = form_class(data=request.POST)
        if form.is_valid():
            email = form.cleaned_data["email"]
            invitation = Invitation.objects.create_invitation(request.user, email)
            invitation.send()
            # success_url needs to be dynamically generated here; setting a
            # a default value using reverse() will cause circular-import
            # problems with the default URLConf for this application, which
            # imports this file.
            return HttpResponseRedirect(success_url or reverse('invitation_complete'))
    else:
        form = form_class()
    context['form'] = form
    return render(request, template_name, context)
def django_settings(request):
    "A context processor that provides django settings"
    s_dict = {}
    for atr in settings.get_all_members():
        if ('A'<atr[0]) and (atr[0]<'Z'):
            s_dict[atr] = settings.__getattr__(atr)
    return s_dict
Beispiel #4
0
def invited(request, invitation_key=None):
    if 'INVITE_MODE' in settings.get_all_members() and settings.INVITE_MODE:
        if invitation_key and is_key_valid(invitation_key):
            template = 'invitation/invited.html'
        else:
            template = 'invitation/wrong_invitation_key.html'
        return direct_to_template(request, template, {'invitation_key': invitation_key})
    else:
        return HttpResponseRedirect(reverse('registration_register'))
Beispiel #5
0
 def _protected(*args, **kwargs):
     from django.conf import settings
     current = dict((key, getattr(settings, key))
                     for key in settings.get_all_members()
                         if key.isupper())
     try:
         return fun(*args, **kwargs)
     finally:
         for key, value in current.items():
             setattr(settings, key, value)
Beispiel #6
0
def invited(request, invitation_key=None):
    if 'INVITE_MODE' in settings.get_all_members() and settings.INVITE_MODE:
        if invitation_key and is_key_valid(invitation_key):
            template = 'invitation/invited.html'
        else:
            template = 'invitation/wrong_invitation_key.html'
        return direct_to_template(request, template,
                                  {'invitation_key': invitation_key})
    else:
        return HttpResponseRedirect(reverse('registration_register'))
def get_authsuburl(request):
  next = "http://%s%s" % (request.get_host(), request.path)
  scope = 'https://spreadsheets.google.com/feeds/'
  secure = False
  session = True

  if 'GOOGLE_SPREADSHEET_DOMAIN' in settings.get_all_members():
     domain = settings.GOOGLE_SPREADSHEET_DOMAIN
  else:
    domain = "default"
   
  gd_client = gdata.spreadsheet.service.SpreadsheetsService()
  return gd_client.GenerateAuthSubURL(next, scope, secure=secure, session=session, domain=domain)
 def remaining_invitations_for_user(self, user):
     """ Returns the number of remaining invitations for a given ``User``
     if ``INVITATIONS_PER_USER`` has been set.
     """
     if 'INVITATIONS_PER_USER' in settings.get_all_members():
         inviteds_count = self.filter(from_user=user).count()
         remaining_invitations = settings.INVITATIONS_PER_USER - inviteds_count
         if remaining_invitations < 0:
             # Possible for admin to change INVITATIONS_PER_USER 
             # to something lower than the initial setting, resulting
             # in a negative value
             return 0
         return remaining_invitations
Beispiel #9
0
def register(request, success_url=None,
            form_class=RegistrationForm, profile_callback=None,
            template_name='registration/registration_form.html',
            extra_context=None):
    if 'INVITE_MODE' in settings.get_all_members() and settings.INVITE_MODE:
        if 'invitation_key' in request.REQUEST \
            and is_key_valid(request.REQUEST['invitation_key']):
            if extra_context is None:
                extra_context = {'invitation_key': request.REQUEST['invitation_key']}
            else:
                extra_context.update({'invitation_key': invitation_key})
            return registration_register(request, success_url, form_class, 
                        profile_callback, template_name, extra_context)
        else:
            return direct_to_template(request, 'invitation/wrong_invitation_key.html')
    else:
        return registration_register(request, success_url, form_class, 
                            profile_callback, template_name, extra_context)
Beispiel #10
0
 def get_page(self):
     django_settings = []
     for name in settings.get_all_members():
         if name != "get_all_members" and not name.startswith("_"):
             value = getattr(settings, name, None)
             django_settings.append("%s = %s" % (name, value))
     os_environ = ["%s = %s" % (key, value) for key, value in os.environ.items()]
     sys_path = sys.path
     cookies = ["%s = %s" % (key, value) for key, value in self.request.COOKIES.items()]
     request_meta = ["%s = %s" % (key, value) for key, value in self.request.META.items()]
     data = {
         "django_settings": django_settings,
         "os_environ": os_environ,
         "sys_path": sys_path,
         "cookies": cookies,
         "request_meta": request_meta,
     }
     return render_to_response(self.get_page_template(), data, RequestContext(self.request))
def Thumbnail(parser, token):
    """
    The parser of the templatetag.

    Should get at least one argument, the filename. If you pass only one, will
try to get a default from DEFAULT_THUMBNAIL_SIZE from the settings module. If
it doesn't exist will default to a width of 150px.

    If you specify a size as well it will be used. In both cases it first tries
to split the string by 'x', if it's not possible uses the entire string. This
is useful because you can specify width and height or just the width.
    """
    bits = token.contents.split()
    if len(bits) in [2, 3]:
        if len(bits) == 3:
            if 'x' in bits[2]:
                dimensions = bits[2].split('x')
            else:
                dimensions = [bits[2], 0]
        else:
            if 'DEFAULT_THUMBNAIL_SIZE' in settings.get_all_members():
                if 'x' in settings.DEFAULT_THUMBNAIL_SIZE:
                    dimensions = settings.DEFAULT_THUMBNAIL_SIZE.split('x')
                else:
                    dimensions = [settings.DEFAULT_THUMBNAIL_SIZE, None]
            else:
                dimensions = [150, 0]

    else:
        raise TemplateSyntaxError, u_(u"thumb recieves two or three \
            arguments, the file to generate the thumbnail from and \
            optionally the size of the resulting thumbnail.")
    for dim in dimensions:
        try:
            int(dim)
        except:
            raise TemplateSyntaxError, u_(u"Tumbnail's size should be given \
                                            in píxels, as just integers.")
    return ResizedThumbnailNode(bits[1], dimensions)
def settings(request):

  d = dict([(k, getattr(django_settings, k)) 
            for k in django_settings.get_all_members()])
  return dict(**d)
Beispiel #13
0
def settings(request):

    d = dict([(k, getattr(django_settings, k))
              for k in django_settings.get_all_members()])
    return dict(**d)
Beispiel #14
0
    (r'^reports/(\d+)/flags/thanks', 'thanks'),
    (r'^reports/(\d+)/flags', 'new'),
)

urlpatterns += patterns('mainapp.views.reports.main',
    (r'^reports/(\d+)$', 'show'),       
    (r'^reports/', 'new'),
)

urlpatterns += patterns('mainapp.views.contact',
    (r'^contact/thanks', 'thanks'),
    (r'^contact', 'new', {}, 'contact_url_name'),
)

urlpatterns += patterns('mainapp.views.ajax',
    (r'^ajax/categories/(\d+)', 'category_desc'),
)

if settings.DEBUG and 'TESTVIEW' in settings.get_all_members():
    urlpatterns += patterns ('',
    (r'^testview',include('django_testview.urls')))


#The following is used to serve up local media files like images
if settings.LOCAL_DEV:
    baseurlregex = r'^media/(?P<path>.*)$'
    urlpatterns += patterns('',
        (baseurlregex, 'django.views.static.serve',
        {'document_root':  settings.MEDIA_ROOT}),
    )
Beispiel #15
0
def settings(request):

  d = dict([(k, util.get_metadata(k))
            for k in django_settings.get_all_members()])
  return dict(**d)