simple changelog
This commit is contained in:
parent
04f994d4b7
commit
e966256fa2
15 changed files with 267 additions and 103 deletions
|
|
@ -8,7 +8,7 @@ import os
|
|||
|
||||
import ox
|
||||
|
||||
from changelog import Changelog
|
||||
from changelog import add_record
|
||||
from oxtornado import actions
|
||||
from utils import update_dict, user_sort_key
|
||||
from . import models
|
||||
|
|
@ -79,9 +79,9 @@ def setPreferences(data):
|
|||
u.update_name()
|
||||
u.save()
|
||||
if change_username:
|
||||
Changelog.record(u, 'editusername', data['username'])
|
||||
add_record('editusername', data['username'])
|
||||
if change_contact:
|
||||
Changelog.record(state.user(), 'editcontact', data['contact'])
|
||||
add_record('editcontact', data['contact'])
|
||||
if change_path:
|
||||
state.tasks.queue('changelibrarypath', change_path)
|
||||
if change_autostart:
|
||||
|
|
@ -227,7 +227,7 @@ def editList(data):
|
|||
validate_query(data['query'])
|
||||
l._query = data['query']
|
||||
if l.type == 'static' and name != l.name:
|
||||
Changelog.record(state.user(), 'editlist', name, {'name': l.name})
|
||||
add_record('editlist', name, {'name': l.name})
|
||||
l.save()
|
||||
return l.json()
|
||||
actions.register(editList, cache=False)
|
||||
|
|
@ -303,7 +303,7 @@ def sortLists(data):
|
|||
state.db.session.add(l)
|
||||
state.db.session.commit()
|
||||
if lists:
|
||||
Changelog.record(state.user(), 'orderlists', lists)
|
||||
add_record('orderlists', lists)
|
||||
return {}
|
||||
actions.register(sortLists, cache=False)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import ox
|
|||
from sqlalchemy.orm import load_only
|
||||
import sqlalchemy as sa
|
||||
|
||||
from changelog import Changelog
|
||||
from changelog import add_record
|
||||
from db import MutableDict
|
||||
import db
|
||||
import json_pickler
|
||||
|
|
@ -159,7 +159,7 @@ class User(db.Model):
|
|||
self.peered = False
|
||||
self.save()
|
||||
if not was_peering:
|
||||
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
||||
add_record('addpeer', self.id, self.nickname)
|
||||
if 'index' not in self.info:
|
||||
self.info['index'] = max([
|
||||
u.info.get('index', -1) for u in User.query.filter_by(peered=True)
|
||||
|
|
@ -182,7 +182,7 @@ class User(db.Model):
|
|||
state.removepeer[self.id] = True
|
||||
self.cleanup()
|
||||
if was_peering:
|
||||
Changelog.record(state.user(), 'removepeer', self.id)
|
||||
add_record('removepeer', self.id)
|
||||
self.save()
|
||||
|
||||
def cleanup(self):
|
||||
|
|
@ -210,6 +210,8 @@ class User(db.Model):
|
|||
self.nickname = nickname
|
||||
|
||||
def rebuild_changelog(self):
|
||||
logger.error('no longer used')
|
||||
return
|
||||
Changelog.query.filter_by(user_id=self.id).delete()
|
||||
for item in self.library.get_items().order_by('created'):
|
||||
Changelog.record(self, 'additem', item.id, item.info, _commit=False)
|
||||
|
|
@ -300,7 +302,7 @@ class List(db.Model):
|
|||
state.db.session.commit()
|
||||
if user_id == settings.USER_ID:
|
||||
if l.type == 'static' and name != '':
|
||||
Changelog.record(state.user(), 'addlist', l.name)
|
||||
add_record('addlist', l.name)
|
||||
return l
|
||||
|
||||
@classmethod
|
||||
|
|
@ -338,7 +340,7 @@ class List(db.Model):
|
|||
if commit:
|
||||
state.db.session.commit()
|
||||
if self.user_id == settings.USER_ID and self.name != '' and available_items:
|
||||
Changelog.record(self.user, 'addlistitems', self.name, available_items)
|
||||
add_record('addlistitems', self.name, available_items)
|
||||
|
||||
def get_items(self):
|
||||
from item.models import Item
|
||||
|
|
@ -359,7 +361,7 @@ class List(db.Model):
|
|||
if commit:
|
||||
state.db.session.commit()
|
||||
if self.user_id == settings.USER_ID and self.name != '':
|
||||
Changelog.record(self.user, 'removelistitems', self.name, items)
|
||||
add_record('removelistitems', self.name, items)
|
||||
|
||||
def remove(self, commit=True):
|
||||
if not self._query:
|
||||
|
|
@ -367,7 +369,7 @@ class List(db.Model):
|
|||
state.db.session.execute(q)
|
||||
if not self._query:
|
||||
if self.user_id == settings.USER_ID and self.name != '':
|
||||
Changelog.record(self.user, 'removelist', self.name)
|
||||
add_record('removelist', self.name)
|
||||
state.db.session.delete(self)
|
||||
if commit:
|
||||
state.db.session.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue