Changeset - e262494ca099
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 12 years ago 2013-05-19 01:36:41
marcin@python-works.com
store download archive actions in journal
3 files changed with 16 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -32,7 +32,7 @@ import shutil
 
from pylons import request, response, tmpl_context as c, url
 
from pylons.i18n.translation import _
 
from pylons.controllers.util import redirect
 
from rhodecode.lib.utils import jsonify
 
from rhodecode.lib.utils import jsonify, action_logger
 

	
 
from rhodecode.lib import diffs
 
from rhodecode.lib import helpers as h
 
@@ -492,7 +492,10 @@ class FilesController(BaseRepoController
 
                        os.remove(archive)
 
                    break
 
                yield data
 

	
 
        # store download action
 
        action_logger(user=c.rhodecode_user,
 
                      action='user_downloaded_archive:%s' % (archive_name),
 
                      repo=repo_name, ipaddr=self.ip_addr, commit=True)
 
        response.content_disposition = str('attachment; filename=%s' % (archive_name))
 
        response.content_type = str(content_type)
 
        return get_chunked_archive(archive)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -684,6 +684,10 @@ def action_parser(user_log, feed=False, 
 
                    url('pullrequest_show', repo_name=repo_name,
 
                    pull_request_id=pull_request_id))
 

	
 
    def get_archive_name():
 
        archive_name = action_params
 
        return archive_name
 

	
 
    # action : translated str, callback(extractor), icon
 
    action_map = {
 
    'user_deleted_repo':           (_('[deleted] repository'),
 
@@ -696,6 +700,8 @@ def action_parser(user_log, feed=False, 
 
                                    get_fork_name, 'arrow_divide.png'),
 
    'user_updated_repo':           (_('[updated] repository'),
 
                                    None, 'database_edit.png'),
 
    'user_downloaded_archive':      (_('[downloaded] archive from repository'),
 
                                    get_archive_name, 'page_white_compressed.png'),
 
    'admin_deleted_repo':          (_('[delete] repository'),
 
                                    None, 'database_delete.png'),
 
    'admin_created_repo':          (_('[created] repository'),
rhodecode/model/db.py
Show inline comments
 
@@ -613,6 +613,11 @@ class UserLog(Base, BaseModel):
 
    action = Column("action", UnicodeText(1200000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
 

	
 
    def __unicode__(self):
 
        return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
 
                                      self.repository_name,
 
                                      self.action)
 

	
 
    @property
 
    def action_as_day(self):
 
        return datetime.date(*self.action_date.timetuple()[:3])
0 comments (0 inline, 0 general)