Beispiel #1
0
 def __init__(self, *args, **kwargs):
   logging.info(">> AdminSiteForm")
   super(AdminSiteForm, self).__init__(*args, **kwargs)
   self.fields['site_name'].initial = ConfigData.get_configdata('SITE_NAME')
   self.fields['meta_description'].initial = ConfigData.get_configdata('SITE_DESCRIPTION')
   self.fields['meta_keywords'].initial = ConfigData.get_configdata('SITE_KEYWORDS')
   self.fields['theme'].widget = forms.Select(choices=Theme.get_choices())
   self.fields['theme'].initial = Theme.get_active().uuid
def get_global_vars():
  params = getattr(settings, 'GLOBALS')
  params.update({'SITE_NAME':ConfigData.get_configdata('SITE_NAME'),
                'SITE_DESCRIPTION':ConfigData.get_configdata('SITE_DESCRIPTION'),
                'SITE_KEYWORDS':ConfigData.get_configdata('SITE_KEYWORDS'),
                'MEDIA_URL':settings.MEDIA_URL,
                'DOMAIN':settings.DOMAIN,
                'THEME_MEDIA_URL':settings.THEME_URL + Theme.get_active().directory_name + '/'})
  return params
  def process_request(self, request):
    if not ConfigData.get_configdata('site_installed', default=False):
      theming.check_themes()
      if not request.path.startswith('/install') and not request.path.startswith('/loader'):
        return http.HttpResponseRedirect(reverse('install'))
      
    if not request.path.startswith('/install') and not request.path.startswith('/loader'):
      for app in settings.INSTALLED_APPS:
        if not ConfigData.is_installed(app):
          try:
            Action.register_action(app)
          except exceptions.ImproperlyConfigured:
            pass #logging.error("   can not register %s actions" % app)

        if not ConfigData.is_installed(app):
          try:
            _install = util.get_attr_from("%s.config.install" % app)
            _install()
          except exceptions.ImproperlyConfigured:
            pass #logging.error("ImproperlyConfigured -> %s.config.install" % app)

          areas = util.get_config_value(app, "areas", {})
          areas_vals = sorted(areas.values(), key=lambda x: x.get("order", 1000))
          
          ConfigData.set_configdata(app, True, label='installed_app',
                                    extra={'adminareas':areas_vals})
Beispiel #4
0
def mail_welcome(user):
  params = {'user':user}
  message = mail.get_mail_message('mail_welcome.txt', **params)
  html_message = mail.get_mail_message('mail_welcome.html', **params)

  subject = "Welcome to %s" % ConfigData.get_configdata('SITE_NAME')
  mail.send_mail(user.email, subject, message, html_message=html_message)
Beispiel #5
0
def mail_confirm(user, mail):
  _link = "http://%s%s" % (settings.DOMAIN, reverse("users_validate_email", args=[code]))
  params = {'user':user, "link": _link}
  message = mail.get_mail_message('mail_validate_email.txt', **params)
  html_message = mail.get_mail_message('mail_validate_email.html', **params)

  subject = "Confirm your %s account" % ConfigData.get_configdata('SITE_NAME')
  
  mail.send_mail(user.email, subject, message, html_message=html_message)
Beispiel #6
0
def register(request):
  form = RegisterForm()
  if request.method == 'POST':
    form = RegisterForm(request.POST)
    if form.is_valid():
      user = form.save()
      mail_welcome(user)
      authenticate(request, user)
      util.add_success(request, "Welcome to %s" % ConfigData.get_configdata('SITE_NAME'))
      return redirect(reverse('admin_dashboard'))

  c = template.RequestContext(request, locals())
  return render_to_response('users_register.html', c)
def install(request):
  area = 'install'

  if ConfigData.get_configdata('site_installed', default=False):
    util.error(request, "Site is already installed")
    return http.HttpResponseRedirect(reverse('front'))
  
  form = InstallForm()
  if request.method == 'POST':
    form = InstallForm(request.POST)
    if form.is_valid():
      user = form.save()
      ConfigData.set_configdata('site_installed', True)
      auth_login(request, user)
      util.success(request, "Site has been installed successfully")
      return http.HttpResponseRedirect(reverse('admin_dashboard'))

  c = template.RequestContext(request, locals())
  _flag_as_admin(c)
  return render_to_response('install.html', c)