mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add created field to models so we can tell if they were originally the same
This commit is contained in:
parent
5856ad7545
commit
f969aec03f
2 changed files with 9 additions and 6 deletions
|
@ -65,20 +65,22 @@ class Model(object):
|
||||||
else:
|
else:
|
||||||
self.id = None
|
self.id = None
|
||||||
self.name = u""
|
self.name = u""
|
||||||
self.mod = intTime()
|
self.crt = intTime()
|
||||||
|
self.mod = self.crt
|
||||||
self.conf = defaultConf.copy()
|
self.conf = defaultConf.copy()
|
||||||
self.css = ""
|
self.css = ""
|
||||||
self.fields = []
|
self.fields = []
|
||||||
self.templates = []
|
self.templates = []
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
(self.mod,
|
(self.crt,
|
||||||
|
self.mod,
|
||||||
self.name,
|
self.name,
|
||||||
self.fields,
|
self.fields,
|
||||||
self.templates,
|
self.templates,
|
||||||
self.conf,
|
self.conf,
|
||||||
self.css) = self.deck.db.first("""
|
self.css) = self.deck.db.first("""
|
||||||
select mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
|
select crt, mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
|
||||||
self.fields = simplejson.loads(self.fields)
|
self.fields = simplejson.loads(self.fields)
|
||||||
self.templates = simplejson.loads(self.templates)
|
self.templates = simplejson.loads(self.templates)
|
||||||
self.conf = simplejson.loads(self.conf)
|
self.conf = simplejson.loads(self.conf)
|
||||||
|
@ -87,8 +89,8 @@ select mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
|
||||||
self.mod = intTime()
|
self.mod = intTime()
|
||||||
self.css = self.genCSS()
|
self.css = self.genCSS()
|
||||||
ret = self.deck.db.execute("""
|
ret = self.deck.db.execute("""
|
||||||
insert or replace into models values (?, ?, ?, ?, ?, ?, ?)""",
|
insert or replace into models values (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||||
self.id, self.mod, self.name,
|
self.id, self.crt, self.mod, self.name,
|
||||||
simplejson.dumps(self.fields),
|
simplejson.dumps(self.fields),
|
||||||
simplejson.dumps(self.templates),
|
simplejson.dumps(self.templates),
|
||||||
simplejson.dumps(self.conf),
|
simplejson.dumps(self.conf),
|
||||||
|
|
|
@ -111,6 +111,7 @@ create table if not exists fsums (
|
||||||
|
|
||||||
create table if not exists models (
|
create table if not exists models (
|
||||||
id integer primary key,
|
id integer primary key,
|
||||||
|
crt integer not null,
|
||||||
mod integer not null,
|
mod integer not null,
|
||||||
name text not null,
|
name text not null,
|
||||||
flds text not null,
|
flds text not null,
|
||||||
|
@ -314,7 +315,7 @@ from facts order by created""")
|
||||||
import anki.models
|
import anki.models
|
||||||
_moveTable(db, "models")
|
_moveTable(db, "models")
|
||||||
db.execute("""
|
db.execute("""
|
||||||
insert into models select id, cast(modified as int),
|
insert into models select id, cast(created as int), cast(modified as int),
|
||||||
name, "{}", "{}", ?, "" from models2""", simplejson.dumps(
|
name, "{}", "{}", ?, "" from models2""", simplejson.dumps(
|
||||||
anki.models.defaultConf))
|
anki.models.defaultConf))
|
||||||
db.execute("drop table models2")
|
db.execute("drop table models2")
|
||||||
|
|
Loading…
Reference in a new issue