Пример #1
0
    def file_filename(instance, filename):
        
        user = get_current_user()
        request = get_current_request()
        fname, dot, extension = filename.rpartition('.')

        dir = settings.MEDIA_ROOT
        dir = os.path.join(dir, unicode(user.get_profile().center.code))
        fname = slugify(fname)
        
        return os.path.join(dir, '%s.%s' % (fname, extension))
Пример #2
0
    def create_user(self, username, password, email,
                             send_email=True, profile_callback=None):

        current_user = get_current_user()
        
        new_user = User.objects.create_user(username, email, password)
        new_user.is_active = True
        new_user.save()

        profile = UserProfile(user=new_user)
        profile.center = current_user.get_profile().center
        profile.save()
    
        return new_user
Пример #3
0
    def iso_filename(instance, filename):
        
        user = get_current_user()
        request = get_current_request()
        fname, dot, extension = filename.rpartition('.')
        extension = "iso"

        try:
            submissions = Submission.objects.all().order_by('-id')
            id = submissions[0].id
        except:
            id = 1

        dir = settings.MEDIA_ROOT
        dir = os.path.join(dir, unicode(user.get_profile().center.code))
        fname = "%s-%s" % (user.get_profile().center.code, id)
        
        return os.path.join(dir, '%s.%s' % (fname, extension))
Пример #4
0
    def save(self, *args, **kwargs):
        """
        Creates the new version, validates and saves it.
        This method has a synchronization bug: we first create a new version no,
        then in other transaction save it.
        """
        if not self.date_created:
            self.date_created = datetime.now()

        if not self.version:
            self.version = self._newversion()

        try:
            self.user_id = get_current_user().id
        except AttributeError:
            self.user_id = None

        self.validate()

        super(PageVersion, self).save()
Пример #5
0
 def save(self):
     self.updated = datetime.now()
     self.updater = get_current_user()
     super(Generic, self).save()
Пример #6
0
 def save(self):
     self.updated = datetime.now()
     if not get_current_user().is_anonymous():
         self.updater = get_current_user()
     super(Generic, self).save()