Merge branch 'development' into fossdb

This commit is contained in:
Kristofers Solo 2023-06-16 19:25:16 +03:00
commit 4889cc0aaf
40 changed files with 89 additions and 94 deletions

8
.github/workflows/ruff.yml vendored Normal file
View File

@ -0,0 +1,8 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1

View File

@ -1,23 +1,18 @@
name: Test name: Django Test
on: on: [push, pull_request]
- push
- pull_request
jobs: jobs:
test: test:
runs-on: ${{ matrix.os }} runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
steps: steps:
- uses: actions/checkout@v2 - name: Checkout code
- name: Set up Python ${{ matrix.python-version }} uses: actions/checkout@v3
uses: actions/setup-python@v2 - name: Set up Python
uses: actions/setup-python@v3
with: with:
python-version: ${{ matrix.python-version }} python-version: "3.10"
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install tox tox-gh-actions pip install -r requirements.txt
- name: Test with tox - name: Run tests
run: tox run: python manage.py test

View File

@ -14,13 +14,16 @@ User = settings.AUTH_USER_MODEL
class Project(models.Model): class Project(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) uuid = models.UUIDField(
primary_key=True, default=uuid.uuid4, editable=False)
author = models.ForeignKey(User, on_delete=models.CASCADE, db_index=True) author = models.ForeignKey(User, on_delete=models.CASCADE, db_index=True)
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
description = models.TextField(blank=True, default="") description = models.TextField(blank=True, default="")
licenses = models.ManyToManyField(License) licenses = models.ManyToManyField(License)
programming_languages = models.ManyToManyField(ProgrammingLanguage, through="ProjectProgrammingLanguage", related_name="projects") programming_languages = models.ManyToManyField(
hosting_platform = models.ManyToManyField(HostingPlatform, through="ProjectHostingPlatform", related_name="projects") ProgrammingLanguage, through="ProjectProgrammingLanguage", related_name="projects")
hosting_platform = models.ManyToManyField(
HostingPlatform, through="ProjectHostingPlatform", related_name="projects")
tag = models.ManyToManyField(Tag) tag = models.ManyToManyField(Tag)
os = models.ManyToManyField(OperatingSystem) os = models.ManyToManyField(OperatingSystem)
star = models.ManyToManyField(Star, related_name="projects_star") star = models.ManyToManyField(Star, related_name="projects_star")
@ -38,5 +41,6 @@ class Project(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.uuid: if not self.uuid:
self.uuid = uuid.uuid3(uuid.uuid4(), f"{self.author.username}-{self.name}") self.uuid = uuid.uuid3(
uuid.uuid4(), f"{self.author.username}-{self.name}")
super().save(*args, **kwargs) super().save(*args, **kwargs)

View File

@ -1,5 +1,5 @@
""" """
ASGI config for FOSSDB_web project. ASGI config for FOSSDB project.
It exposes the ASGI callable as a module-level variable named ``application``. It exposes the ASGI callable as a module-level variable named ``application``.
@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FOSSDB_web.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FOSSDB.settings")
application = get_asgi_application() application = get_asgi_application()

View File

@ -1,5 +1,5 @@
""" """
Django settings for FOSSDB_web project. Django settings for FOSSDB project.
Generated by "django-admin startproject" using Django 4.0.5. Generated by "django-admin startproject" using Django 4.0.5.
@ -16,7 +16,7 @@ from pathlib import Path
# Build paths inside the project like this: BASE_DIR / "subdir". # Build paths inside the project like this: BASE_DIR / "subdir".
BASE_PATH = Path(__file__).resolve().parent.parent BASE_PATH = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(BASE_PATH.joinpath("FOSSDB_web", "apps"))) sys.path.insert(0, str(BASE_PATH.joinpath("FOSSDB", "apps")))
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
@ -56,7 +56,7 @@ MIDDLEWARE = [
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
] ]
ROOT_URLCONF = "FOSSDB_web.urls" ROOT_URLCONF = "FOSSDB.urls"
TEMPLATES = [ TEMPLATES = [
{ {
@ -74,7 +74,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = "FOSSDB_web.wsgi.application" WSGI_APPLICATION = "FOSSDB.wsgi.application"
# Database # Database

View File

@ -1,4 +1,4 @@
"""FOSSDB_web URL Configuration """FOSSDB URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/ https://docs.djangoproject.com/en/4.0/topics/http/urls/

View File

@ -1,5 +1,5 @@
""" """
WSGI config for FOSSDB_web project. WSGI config for FOSSDB project.
It exposes the WSGI callable as a module-level variable named ``application``. It exposes the WSGI callable as a module-level variable named ``application``.
@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FOSSDB_web.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FOSSDB.settings")
application = get_wsgi_application() application = get_wsgi_application()

52
README.md Normal file
View File

@ -0,0 +1,52 @@
# FOSSDB
[![License](https://img.shields.io/badge/license-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
![Django Test](https://github.com/kristoferssolo/FOSSDB/actions/workflows/test.yml/badge.svg)
![Ruff](https://github.com/kristoferssolo/FOSSDB/actions/workflows/ruff.yml/badge.svg)
FOSSDB is an open-source web application that helps users find, contribute, and collaborate on free and open-source software (FOSS) projects.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
## Installation
1. Clone the repository and `cd` into it.
2. Install dependencies:
```sh
pip install -r requirements.txt
```
3. Enter your `SECRET_KEY` and database information into `config.json` file.
4. Run database migrations:
```sh
python manage.py migrate
```
5. Create a superuser:
```sh
python manage.py createsuperuser
```
6. Run the development server:
```sh
python manage.py runserver
```
## Usage
After following the installation steps, you can access the application at [https://localhost:8000](https://localhost:8000).
Here are some of the features:
- Browse projects by programming language, license, or search term
- View project details, including programming languages, licenses, and descriptions
- Create a new project and add programming languages and licenses
- Edit and delete existing projects
## Contributing
Contributions are always welcome! Here are some ways to get started:
1. Fork the repository and make your changes.
2. Submit a pull request.
3. Respond to open issues or submit new ones.
4. Improve documentation.
## License
This project is licensed under the [GPL3 License](https://www.gnu.org/licenses/gpl-3.0.en.html). See the [LICENSE](./LICENSE) file for details.

View File

@ -6,7 +6,7 @@ import sys
def main(): def main():
"""Run administrative tasks.""" """Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FOSSDB_web.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FOSSDB.settings")
try: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc:

View File

@ -1,35 +0,0 @@
[metadata]
name = FOSSDB-Web
description = Open-Source Software Database Website
author = Kristofers Solo
license = GPL3
license_files = LICENSE
platforms = unix, linux, osx, cygwin, win32
classifiers =
Programming Language :: Python :: 3.10
[options]
packages = FOSSDB_web
install_requires =
Django>=4.1
Pillow>=9.4.0
fontawesomefree>=6.2.1
mysqlclient>=2.1.1
python_requires = >=3.10
package_dir = =.
zip_safe = no
[options.extras_require]
testing =
flake8>=6.0.0
mypy>=0.991
pytest-cov>=4.0.0
pytest>=7.2.0
tox>=3.27.1
[options.package_data]
detector = py.typed
[flake8]
max-line-length = 160

View File

@ -1,4 +0,0 @@
from setuptools import setup
if __name__ == "__main__":
setup()

25
tox.ini
View File

@ -1,25 +0,0 @@
[tox]
minversion = 3.8.0
envlist = django, flake8, mypy
isolated_build = true
[gh-actions]
python =
3.10: django, mypy, flake8
[testenv:django]
basepython = python3.10
deps = django
commands = python manage.py test
[testenv:flake8]
basepython = python3.10
deps = flake8
commands = flake8 FOSSDB_web
[testenv:mypy]
basepython = python3.10
deps =
-r{toxinidir}/requirements_dev.txt
commands = mypy FOSSDB_web