Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Rewrite Models and handle GitHub events #17

Merged
merged 24 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b03bf63
Rewrite models
TheKaram Sep 19, 2022
3caee2d
Refactoring the code; rename translate to translation
TheKaram Sep 20, 2022
a009099
format code with black
TheKaram Sep 20, 2022
b2cf3df
A partial fix for the slowness in the update source function & fix so…
TheKaram Sep 21, 2022
0d69296
Sort imports using isort
TheKaram Sep 21, 2022
baa099f
fix UserTranslation ordering
TheKaram Sep 22, 2022
fec7fdb
Add Moderator Model in github_manager
TheKaram Sep 22, 2022
75a3c75
Clearify push function name
TheKaram Sep 22, 2022
98a4a94
Edit PR & Word relationship to ForeignKey
TheKaram Sep 26, 2022
b1ba201
Edit json example format
TheKaram Sep 26, 2022
4b72774
Fix type annotation
TheKaram Sep 26, 2022
0eb5b6b
Fix deleted words error on get word objects
TheKaram Sep 26, 2022
2c29dc4
Fix: reverse ordering in translation
TheKaram Sep 27, 2022
e2bcef1
Change prid to number in PullRequest
TheKaram Sep 30, 2022
b914a54
fix: Send words that are in pullrequest
TheKaram Oct 2, 2022
fde545f
Add Moderator to django admin
TheKaram Oct 3, 2022
5ca6334
Fix: get_all_moderators function
TheKaram Oct 3, 2022
b26b63e
remove localhost from ALLOWED_HOSTS
TheKaram Oct 3, 2022
c48cf64
Update generate_dict_from_db
TheKaram Oct 3, 2022
b116c66
github_manager: Handle pull request events and add make_pull_request …
TheKaram Oct 3, 2022
015639e
github_manager: handle pull request comments events
TheKaram Oct 3, 2022
e81fc28
use black & isort
TheKaram Oct 3, 2022
3824e8f
fix: deleted words error if the local json empty
TheKaram Oct 5, 2022
b159417
some improvements
TheKaram Oct 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ipaddress = "*"

[dev-packages]
ipython = "*"
isort = "*"

[requires]
python_version = "3.10"
16 changes: 12 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions cache_json/admin.py

This file was deleted.

22 changes: 0 additions & 22 deletions cache_json/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions cache_json/views.py

This file was deleted.

7 changes: 5 additions & 2 deletions github_manager/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from django.contrib import admin
from .models import PullRequest

from .models import Moderator, PullRequest

# Register your models here.
admin.site.register(PullRequest)
admin.site.register(PullRequest)
admin.site.register(Moderator)
8 changes: 8 additions & 0 deletions github_manager/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pull_request": {
"title": "Change '{word}' Translation to '{translation}'",
"head": "'{word}' has reached the minimum translations limit\nThe New default Translation is: '{translation}'\n\nThese are the 5 most commoun translations:\n",
"other_translation": "{index}. '{translation}'",
"footer": "To change the default translation, write: /set-default NumberOfTranslation\nTo delete Specific translation, write: /delete NumberOfTranslation"
}
}
31 changes: 28 additions & 3 deletions github_manager/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
# Generated by Django 4.1.1 on 2022-09-17 18:03
# Generated by Django 4.1.1 on 2022-09-30 08:32

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []
dependencies = [
("translation", "0001_initial"),
]

operations = [
migrations.CreateModel(
name="Moderator",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("username", models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name="PullRequest",
fields=[
Expand All @@ -22,7 +40,14 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
("prid", models.IntegerField()),
("number", models.IntegerField()),
(
"word",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="translation.word",
),
),
],
),
]
12 changes: 11 additions & 1 deletion github_manager/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
from django.db import models


# Create your models here.
class PullRequest(models.Model):
prid = models.IntegerField()
number = models.IntegerField()
word = models.ForeignKey("translation.Word", on_delete=models.CASCADE)


class Moderator(models.Model):
username = models.CharField(max_length=255)

@classmethod
def get_all_moderators(cls) -> list[str]:
return [mod.username for mod in cls.objects.all()]
Loading