Esempio n. 1
0
def add_cell_text(id):
    cell = SplitFile.get(SplitFile.id == id)
    text = request.form['text']
    Text.create(source=cell, method='manual',
            text=text, user_id=request.form['user_id'])
    flash("Text version '{}' added.".format(text), 'success')

    return redirect_back(url_for('cell', id=id))
Esempio n. 2
0
def handle_text(sender, **kwargs): 
    filename = kwargs.get('source_filename')
    md5 = kwargs.get('source_md5')
    method = kwargs.get('method')
    user = kwargs.get('user')
    text = kwargs.get('text')

    source = SplitFile.get(SplitFile.filename == filename, SplitFile.md5 == md5)
    Text.create(source=source, user_id=user, text=text, method=method)
Esempio n. 3
0
    def update(self, pk):
        try:
            text = Text.get(Text.id == pk)
        except Text.DoesNotExist:
            text = Text()

        source = SplitFile.get(SplitFile.id == self.data['source'])
        text.source = source
        text.text = self.data['text']
        text.accepted = self.data['accepted']
        text.save()
        return text
Esempio n. 4
0
def cell(id):
    cell = SplitFile.get(SplitFile.id == id)
    source_file = cell.source.source
    project = source_file.project
    label = "Row {}, Column {}".format(cell.row, cell.column)
    next_view = get_redirect_target()
    breadcrumbs = [
        (project.name, url_for('project', slug=project.slug)),
        (source_file.filename,
         url_for('source_file', id=source_file.id)),
        (cell.source.filename, url_for('image_file', id=cell.source.id)),
        (label, None),
    ]
    return render_template('cell.html', cell=cell, breadcrumbs=breadcrumbs,
        next=next_view)
Esempio n. 5
0
 def create(self):
     source = SplitFile.get(SplitFile.id == self.data['source'])
     return Text.create(source=source, method='manual',
         text=self.data['text'], user_id=self.data['user_id'])