mirror of https://codeberg.org/dribdat/dribdat.git
Added autotext field
This commit is contained in:
parent
996b5454b4
commit
e1c541371d
|
@ -26,6 +26,7 @@ pip-log.txt
|
|||
nosetests.xml
|
||||
.cache
|
||||
tests/.cache
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
|
|
@ -69,11 +69,11 @@
|
|||
},
|
||||
"bleach": {
|
||||
"hashes": [
|
||||
"sha256:0ee95f6167129859c5dce9b1ca291ebdb5d8cd7e382ca0e237dfd0dad63f63d8",
|
||||
"sha256:24754b9a7d530bf30ce7cbc805bc6cce785660b4a10ff3a43633728438c105ab"
|
||||
"sha256:48d39675b80a75f6d1c3bdbffec791cf0bbbab665cf01e20da701c77de278718",
|
||||
"sha256:73d26f018af5d5adcdabf5c1c974add4361a9c76af215fe32fdec8a6fc5fb9b9"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.1.4"
|
||||
"version": "==3.0.2"
|
||||
},
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
|
@ -128,11 +128,11 @@
|
|||
},
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
|
||||
"sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
|
||||
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
|
||||
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==6.7"
|
||||
"version": "==7.0"
|
||||
},
|
||||
"cssmin": {
|
||||
"hashes": [
|
||||
|
@ -266,13 +266,6 @@
|
|||
"index": "pypi",
|
||||
"version": "==19.9.0"
|
||||
},
|
||||
"html5lib": {
|
||||
"hashes": [
|
||||
"sha256:20b159aa3badc9d5ee8f5c647e5efd02ed2a66ab8d354930bd9ff139fc1dc0a3",
|
||||
"sha256:66cb0dcfdbbc4f9c3ba1a63fdb511ffdbd4f513b2b6d81b80cd26ce6b3fb3736"
|
||||
],
|
||||
"version": "==1.0.1"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
|
||||
|
@ -359,10 +352,10 @@
|
|||
},
|
||||
"promise": {
|
||||
"hashes": [
|
||||
"sha256:0bca4ed933e3d50e3d18fb54fc1432fa84b0564838cd093e824abcd718ab9304",
|
||||
"sha256:95506bac89df7a495e0b8c813fd782dd1ae590decb52f95248e316c6659ca49b"
|
||||
"sha256:2ebbfc10b7abf6354403ed785fe4f04b9dfd421eb1a474ac8d187022228332af",
|
||||
"sha256:348f5f6c3edd4fd47c9cd65aed03ac1b31136d375aa63871a57d3e444c85655c"
|
||||
],
|
||||
"version": "==2.1"
|
||||
"version": "==2.2.1"
|
||||
},
|
||||
"psycopg2": {
|
||||
"hashes": [
|
||||
|
@ -464,14 +457,6 @@
|
|||
"index": "pypi",
|
||||
"version": "==1.2.12"
|
||||
},
|
||||
"typing": {
|
||||
"hashes": [
|
||||
"sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d",
|
||||
"sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4",
|
||||
"sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a"
|
||||
],
|
||||
"version": "==3.6.6"
|
||||
},
|
||||
"urllib3": {
|
||||
"hashes": [
|
||||
"sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
|
||||
|
@ -540,11 +525,11 @@
|
|||
},
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
|
||||
"sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
|
||||
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
|
||||
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==6.7"
|
||||
"version": "==7.0"
|
||||
},
|
||||
"factory-boy": {
|
||||
"hashes": [
|
||||
|
@ -556,10 +541,10 @@
|
|||
},
|
||||
"faker": {
|
||||
"hashes": [
|
||||
"sha256:74b32991f8e08e4f2f84858b919eca253becfaec4b3fa5fcff7fdbd70d5d78b1",
|
||||
"sha256:c2ce42dd8361e6d392276006d757532562463c8642b1086709584200b7fd7758"
|
||||
"sha256:2621643b80a10b91999925cfd20f64d2b36f20bf22136bbdc749bb57d6ffe124",
|
||||
"sha256:5ed822d31bd2d6edf10944d176d30dc9c886afdd381eefb7ba8b7aad86171646"
|
||||
],
|
||||
"version": "==0.9.1"
|
||||
"version": "==0.9.2"
|
||||
},
|
||||
"flake8": {
|
||||
"hashes": [
|
||||
|
@ -693,10 +678,10 @@
|
|||
},
|
||||
"py": {
|
||||
"hashes": [
|
||||
"sha256:06a30435d058473046be836d3fc4f27167fd84c45b99704f2fb5509ef61f9af1",
|
||||
"sha256:50402e9d1c9005d759426988a492e0edaadb7f4e68bcddfea586bc7432d009c6"
|
||||
"sha256:bf92637198836372b520efcba9e020c330123be8ce527e535d185ed4b6f45694",
|
||||
"sha256:e76826342cefe3c3d5f7e8ee4316b80d1dd8a300781612ddbc765c17ba25a6c6"
|
||||
],
|
||||
"version": "==1.6.0"
|
||||
"version": "==1.7.0"
|
||||
},
|
||||
"pycodestyle": {
|
||||
"hashes": [
|
||||
|
@ -707,11 +692,11 @@
|
|||
},
|
||||
"pydocstyle": {
|
||||
"hashes": [
|
||||
"sha256:08a870edc94508264ed90510db466c6357c7192e0e866561d740624a8fc7d90c",
|
||||
"sha256:4d5bcde961107873bae621f3d580c3e35a426d3687ffc6f8fb356f6628da5a97",
|
||||
"sha256:af9fcccb303899b83bec82dc9a1d56c60fc369973223a5e80c3dfa9bdf984405"
|
||||
"sha256:2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8",
|
||||
"sha256:5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4",
|
||||
"sha256:ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039"
|
||||
],
|
||||
"version": "==2.1.1"
|
||||
"version": "==3.0.0"
|
||||
},
|
||||
"pyflakes": {
|
||||
"hashes": [
|
||||
|
@ -722,11 +707,11 @@
|
|||
},
|
||||
"pytest": {
|
||||
"hashes": [
|
||||
"sha256:453cbbbe5ce6db38717d282b758b917de84802af4288910c12442984bde7b823",
|
||||
"sha256:a8a07f84e680482eb51e244370aaf2caa6301ef265f37c2bdefb3dd3b663f99d"
|
||||
"sha256:7e258ee50338f4e46957f9e09a0f10fb1c2d05493fa901d113a8dafd0790de4e",
|
||||
"sha256:9332147e9af2dcf46cd7ceb14d5acadb6564744ddff1fe8c17f0ce60ece7d9a2"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.8.0"
|
||||
"version": "==3.8.2"
|
||||
},
|
||||
"python-dateutil": {
|
||||
"hashes": [
|
||||
|
@ -779,11 +764,11 @@
|
|||
},
|
||||
"webtest": {
|
||||
"hashes": [
|
||||
"sha256:0c08a44bb03dcb2f5ca61d40bd5b4638e74a564d4ec7848098f419a5fa078dfe",
|
||||
"sha256:5c69f73cc58bef355e919ff96054b68cbaecc7d970b60b602568d3d92ca967d5"
|
||||
"sha256:4221020d502ff414c5fba83c1213985b83219cb1cc611fe58aa4feaf96b5e062",
|
||||
"sha256:9f1e6faad0b732911793e4d6f54aede292b0c3ee0b3ef7afb2011ec4f4044cc8"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.0.30"
|
||||
"version": "==2.0.32"
|
||||
},
|
||||
"werkzeug": {
|
||||
"hashes": [
|
||||
|
|
|
@ -53,7 +53,8 @@ class ProjectForm(FlaskForm):
|
|||
is_autoupdate = BooleanField(u'Autoupdate project data')
|
||||
name = StringField(u'Title', [required(), length(max=80), UniqueValidator(Project, 'name')])
|
||||
summary = StringField(u'Short summary', [length(max=120)])
|
||||
longtext = TextAreaField(u'Full description')
|
||||
longtext = TextAreaField(u'Description')
|
||||
autotext = TextAreaField(u'Readme content')
|
||||
webpage_url = StringField(u'Web page link', [length(max=255)])
|
||||
source_url = StringField(u'Source code link', [length(max=255)])
|
||||
contact_url = StringField(u'Contact link', [length(max=255)])
|
||||
|
|
|
@ -162,6 +162,7 @@ def project_search_json():
|
|||
Project.name.like(q),
|
||||
Project.summary.like(q),
|
||||
Project.longtext.like(q),
|
||||
Project.autotext.like(q),
|
||||
)).limit(5).all()
|
||||
return jsonify(projects=[p.data for p in projects])
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from flask_wtf import FlaskForm
|
|||
from wtforms import (
|
||||
SubmitField, BooleanField,
|
||||
StringField, PasswordField,
|
||||
TextAreaField, TextField,
|
||||
TextAreaField,
|
||||
SelectField, HiddenField,
|
||||
RadioField
|
||||
)
|
||||
|
|
|
@ -145,19 +145,22 @@ def project_autoupdate(project_id):
|
|||
if not 'name' in data:
|
||||
flash("Project could not be synced: check the Remote Link.", 'warning')
|
||||
return project_action(project_id, None)
|
||||
if 'name' in data and data['name']:
|
||||
project.name = data['name']
|
||||
if 'summary' in data and data['summary']:
|
||||
project.summary = data['summary']
|
||||
# Project name is not updated
|
||||
# if 'name' in data and data['name']: project.name = data['name']
|
||||
# Always update "autotext" field
|
||||
if 'description' in data and data['description']:
|
||||
project.longtext = data['description']
|
||||
if 'homepage_url' in data and data['homepage_url']:
|
||||
project.autotext = data['description']
|
||||
# Update following fields only if blank
|
||||
if 'summary' in data and data['summary']:
|
||||
if not project.summary or not project.summary.strip():
|
||||
project.summary = data['summary']
|
||||
if 'homepage_url' in data and data['homepage_url'] and not project.webpage_url:
|
||||
project.webpage_url = data['homepage_url']
|
||||
if 'contact_url' in data and data['contact_url']:
|
||||
if 'contact_url' in data and data['contact_url'] and not project.contact_url:
|
||||
project.contact_url = data['contact_url']
|
||||
if 'source_url' in data and data['source_url']:
|
||||
if 'source_url' in data and data['source_url'] and not project.source_url:
|
||||
project.source_url = data['source_url']
|
||||
if 'image_url' in data and data['image_url']:
|
||||
if 'image_url' in data and data['image_url'] and not project.image_url:
|
||||
project.image_url = data['image_url']
|
||||
project.update()
|
||||
db.session.add(project)
|
||||
|
|
|
@ -315,7 +315,7 @@ nav .navbar-nav .nav-item {
|
|||
list-style: none; color: #777;
|
||||
}
|
||||
.project-page .history span {
|
||||
font-size: 90%; color: #aaa;
|
||||
font-size: 90%; color: #aaa;
|
||||
}
|
||||
.project-page .history li:hover{
|
||||
background: #fff;
|
||||
|
@ -333,7 +333,7 @@ nav .navbar-nav .nav-item {
|
|||
.project-page .project-star i {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.project-page .project-longtext img {
|
||||
.project-page img {
|
||||
max-width: 100%;
|
||||
}
|
||||
.project-page.jumbotron { padding: 1rem; }
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
|
||||
$('input#name').val(data.name);
|
||||
$('input#summary').val(data.summary);
|
||||
$('textarea#longtext').html(data.description);
|
||||
// $('textarea#longtext').html(excerpt);
|
||||
$('input#webpage_url').val(data.homepage_url);
|
||||
$('input#source_url').val(data.source_url);
|
||||
$('input#contact_url').val(data.contact_url);
|
||||
|
|
|
@ -97,11 +97,19 @@
|
|||
</a>
|
||||
{% endif %}
|
||||
|
||||
<br clear="all"><hr>
|
||||
<br clear="all">
|
||||
|
||||
{% if project.longtext %}
|
||||
<div class="project-longtext">
|
||||
{{project.longtext|markdown}}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if project.autotext %}
|
||||
<div class="project-autotext">
|
||||
{{project.autotext|markdown}}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="btn-group project-buttons" role="group" aria-label="Hackathon navigation">
|
||||
{% if project.webpage_url %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import TextField, PasswordField, StringField
|
||||
from wtforms import PasswordField, StringField
|
||||
from wtforms.validators import DataRequired, Email, EqualTo, Length
|
||||
|
||||
from .models import User
|
||||
|
@ -17,7 +17,7 @@ class RegisterForm(FlaskForm):
|
|||
validators=[DataRequired(), Length(min=6, max=40)])
|
||||
confirm = PasswordField('Verify password',
|
||||
[DataRequired(), EqualTo('password', message='Passwords must match')])
|
||||
webpage_url = TextField(u'Online profile')
|
||||
webpage_url = StringField(u'Online profile')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Create instance."""
|
||||
|
|
|
@ -212,11 +212,12 @@ class Project(SurrogatePK, Model):
|
|||
contact_url = Column(db.String(255), nullable=True)
|
||||
autotext_url = Column(db.String(255), nullable=True)
|
||||
is_autoupdate = Column(db.Boolean(), default=True)
|
||||
autotext = Column(db.UnicodeText(), nullable=True, default=u"")
|
||||
longtext = Column(db.UnicodeText(), nullable=False, default=u"")
|
||||
hashtag = Column(db.String(40), nullable=True)
|
||||
logo_color = Column(db.String(7), nullable=True)
|
||||
logo_icon = Column(db.String(40), nullable=True)
|
||||
longtext = Column(db.UnicodeText(), nullable=False, default=u"")
|
||||
|
||||
hashtag = Column(db.String(40), nullable=True)
|
||||
created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
|
||||
updated_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
|
||||
is_hidden = Column(db.Boolean(), default=False)
|
||||
|
@ -324,6 +325,10 @@ class Project(SurrogatePK, Model):
|
|||
if len(self.longtext) > 3: score = score + 1
|
||||
if len(self.longtext) > 100: score = score + 4
|
||||
if len(self.longtext) > 500: score = score + 10
|
||||
if self.autotext is not None:
|
||||
if len(self.autotext) > 3: score = score + 1
|
||||
if len(self.autotext) > 100: score = score + 4
|
||||
if len(self.autotext) > 500: score = score + 10
|
||||
self.score = score
|
||||
|
||||
def __init__(self, name=None, **kwargs):
|
||||
|
|
10
manage.py
10
manage.py
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import click
|
||||
|
||||
from flask import Flask
|
||||
from flask.cli import FlaskGroup
|
||||
|
@ -26,18 +27,19 @@ def create_app(script_info=None):
|
|||
else:
|
||||
app = init_app(DevConfig)
|
||||
app.shell_context_processor(shell_context)
|
||||
app.cli.add_command('db', MigrateCommand)
|
||||
return app
|
||||
|
||||
cli = FlaskGroup(create_app=create_app)
|
||||
@click.group(cls=FlaskGroup, create_app=create_app)
|
||||
def cli():
|
||||
"""This is a management script for the wiki application."""
|
||||
|
||||
@cli.command
|
||||
@click.command
|
||||
def test():
|
||||
"""Run the tests."""
|
||||
import pytest
|
||||
exit_code = pytest.main([TEST_PATH, '--verbose'])
|
||||
return exit_code
|
||||
|
||||
cli.add_command('db', MigrateCommand)
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
||||
|
|
Loading…
Reference in New Issue