Add ordering to boards, create default board
This commit is contained in:
64
boards.yml
64
boards.yml
@@ -1,4 +1,68 @@
|
||||
boards:
|
||||
- name: Технологии
|
||||
slug: tech
|
||||
is_visible: true
|
||||
is_private: false
|
||||
curator:
|
||||
name: Технологии
|
||||
title: Новости айти
|
||||
avatar: https://i.vas3k.ru/fhr.png
|
||||
bio: Подборка СМИ
|
||||
footer: >
|
||||
это общая подборка всех популярных технологических СМИ. Фиды обновляются раз в час.
|
||||
blocks:
|
||||
- name: На русском
|
||||
slug: ru
|
||||
feeds:
|
||||
- name: VC
|
||||
url: https://vc.ru
|
||||
rss: https://vc.ru/rss/all
|
||||
- name: TJ
|
||||
url: https://tjournal.ru
|
||||
rss: https://tjournal.ru/rss/all
|
||||
- name: "Хабр: лучшее за сутки"
|
||||
url: https://habr.ru
|
||||
rss: https://habr.com/ru/rss/best/daily/?fl=ru
|
||||
- name: На английском
|
||||
slug: en
|
||||
feeds:
|
||||
- name: TechCrunch
|
||||
rss: http://feeds.feedburner.com/TechCrunch/
|
||||
url: https://techcrunch.com
|
||||
- name: Engadget
|
||||
rss: https://www.engadget.com/rss.xml
|
||||
url: https://www.engadget.com
|
||||
- name: Gizmodo
|
||||
url: https://gizmodo.com
|
||||
rss: https://gizmodo.com/rss
|
||||
- name: Wired
|
||||
url: https://www.wired.com
|
||||
rss: https://www.wired.com/feed/rss
|
||||
icon: https://i.vas3k.ru/feu.png
|
||||
- name: VentureBeat
|
||||
url: https://venturebeat.com
|
||||
rss: http://feeds.feedburner.com/venturebeat/SZYF
|
||||
- name: ZDNet
|
||||
rss: https://www.zdnet.com/news/rss.xml
|
||||
url: https://www.zdnet.com
|
||||
- name: CNET
|
||||
url: https://www.cnet.com/topics/tech-industry/
|
||||
rss: http://feed.cnet.com/feed/topics/tech-industry
|
||||
- name: The Verge
|
||||
rss: https://www.theverge.com/rss/index.xml
|
||||
url: https://www.theverge.com
|
||||
- name: The Next Web
|
||||
rss: http://feeds2.feedburner.com/thenextweb
|
||||
url: https://thenextweb.com
|
||||
- name: ArsTechnica
|
||||
rss: http://feeds.arstechnica.com/arstechnica/index/
|
||||
url: https://arstechnica.com
|
||||
- name: ReadWrite
|
||||
url: https://readwrite.com
|
||||
rss: https://readwrite.com/feed/
|
||||
- name: Slashdot
|
||||
rss: http://rss.slashdot.org/Slashdot/slashdotMain
|
||||
url: https://slashdot.org
|
||||
- name: Вастрик
|
||||
slug: vas3k
|
||||
is_visible: true
|
||||
|
||||
22
boards/migrations/0003_auto_20200106_2228.py
Normal file
22
boards/migrations/0003_auto_20200106_2228.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 2.2.8 on 2020-01-06 22:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('boards', '0002_article_summary'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='board',
|
||||
options={'ordering': ['index']},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='board',
|
||||
name='index',
|
||||
field=models.PositiveIntegerField(default=0),
|
||||
),
|
||||
]
|
||||
@@ -29,10 +29,11 @@ class Board(models.Model):
|
||||
|
||||
is_visible = models.BooleanField(default=True)
|
||||
is_private = models.BooleanField(default=True)
|
||||
index = models.PositiveIntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
db_table = "boards"
|
||||
ordering = ["name"]
|
||||
ordering = ["index", "name"]
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.created_at:
|
||||
|
||||
@@ -5,7 +5,7 @@ from boards.models import Board, BoardBlock, BoardFeed
|
||||
|
||||
|
||||
def index(request):
|
||||
boards = Board.objects.filter(is_visible=True).order_by("created_at")
|
||||
boards = Board.objects.filter(is_visible=True).all()
|
||||
return render(request, "index.html", {
|
||||
"boards": boards
|
||||
})
|
||||
|
||||
@@ -37,7 +37,7 @@ def initialize(config, board_slug, upload_favicons):
|
||||
print(f"Bad YAML file '{yaml_file}': {ex}")
|
||||
exit(1)
|
||||
|
||||
for board_config in config["boards"]:
|
||||
for board_index, board_config in enumerate(config["boards"]):
|
||||
if board_slug and board_config["slug"] != board_slug:
|
||||
continue
|
||||
|
||||
@@ -55,6 +55,7 @@ def initialize(config, board_slug, upload_favicons):
|
||||
curator_url=board_config["curator"].get("url"),
|
||||
is_private=board_config.get("is_private"),
|
||||
is_visible=board_config.get("is_visible"),
|
||||
index=board_index,
|
||||
)
|
||||
)
|
||||
if not is_created:
|
||||
@@ -68,6 +69,7 @@ def initialize(config, board_slug, upload_favicons):
|
||||
board.curator_url = board_config["curator"].get("url")
|
||||
board.is_private = board_config.get("is_private")
|
||||
board.is_visible = board_config.get("is_visible")
|
||||
board.index = board_index
|
||||
board.save()
|
||||
|
||||
for block_index, block_config in enumerate(board_config["blocks"]):
|
||||
|
||||
Reference in New Issue
Block a user