Skip to content

Commit 68d06ae

Browse files
committed
Fixed conflict
2 parents 2a60bfb + a04bab5 commit 68d06ae

26 files changed

+1023
-112
lines changed

lms/lmsdb/models.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
class RoleOptions(enum.Enum):
3636
BANNED = 'Banned'
37+
UNVERIFIED = 'Unverified'
3738
STUDENT = 'Student'
3839
STAFF = 'Staff'
3940
VIEWER = 'Viewer'
@@ -67,6 +68,7 @@ class Role(BaseModel):
6768
(RoleOptions.STAFF.value, RoleOptions.STAFF.value),
6869
(RoleOptions.VIEWER.value, RoleOptions.VIEWER.value),
6970
(RoleOptions.STUDENT.value, RoleOptions.STUDENT.value),
71+
(RoleOptions.UNVERIFIED.value, RoleOptions.UNVERIFIED.value),
7072
(RoleOptions.BANNED.value, RoleOptions.BANNED.value),
7173
))
7274

@@ -77,6 +79,10 @@ def __str__(self):
7779
def get_banned_role(cls) -> 'Role':
7880
return cls.get(Role.name == RoleOptions.BANNED.value)
7981

82+
@classmethod
83+
def get_unverified_role(cls) -> 'Role':
84+
return cls.get(Role.name == RoleOptions.UNVERIFIED.value)
85+
8086
@classmethod
8187
def get_student_role(cls) -> 'Role':
8288
return cls.get(Role.name == RoleOptions.STUDENT.value)
@@ -100,6 +106,10 @@ def by_name(cls, name) -> 'Role':
100106
def is_banned(self) -> bool:
101107
return self.name == RoleOptions.BANNED.value
102108

109+
@property
110+
def is_unverified(self) -> bool:
111+
return self.name == RoleOptions.UNVERIFIED.value
112+
103113
@property
104114
def is_student(self) -> bool:
105115
return self.name == RoleOptions.STUDENT.value
@@ -458,8 +468,7 @@ def set_state(self, new_state: SolutionState, **kwargs) -> bool:
458468
**{Solution.state.name: new_state.name},
459469
**kwargs,
460470
).where(requested_solution)
461-
updated = changes.execute() == 1
462-
return updated
471+
return changes.execute() == 1
463472

464473
def ordered_versions(self) -> Iterable['Solution']:
465474
return Solution.select().where(

lms/lmsweb/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from flask_babel import Babel # type: ignore
66
from flask_limiter import Limiter # type: ignore
77
from flask_limiter.util import get_remote_address # type: ignore
8+
from flask_mail import Mail # type: ignore
89
from flask_wtf.csrf import CSRFProtect # type: ignore
910

1011
from lms.utils import config_migrator, debug
@@ -41,6 +42,8 @@
4142
# Localizing configurations
4243
babel = Babel(webapp)
4344

45+
webmail = Mail(webapp)
46+
4447

4548
# Must import files after app's creation
4649
from lms.lmsdb import models # NOQA: F401, E402, I202

lms/lmsweb/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ class AdminCommentTextView(AdminModelView):
6969
admin = Admin(
7070
webapp,
7171
name='LMS',
72-
template_mode='bootstrap3',
72+
template_mode='bootstrap4',
7373
index_view=MyAdminIndexView(), # NOQA
7474
)

lms/lmsweb/config.py.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ SECRET_KEY = ''
88
MAILGUN_API_KEY = os.getenv('MAILGUN_API_KEY')
99
MAILGUN_DOMAIN = os.getenv('MAILGUN_DOMAIN', 'mail.pythonic.guru')
1010
SERVER_ADDRESS = os.getenv('SERVER_ADDRESS', '127.0.0.1:5000')
11+
SITE_NAME = 'Learning Python'
12+
13+
# REGISTRATION CONFIGURATIONS
14+
REGISTRATION_OPEN = True
15+
CONFIRMATION_TIME = 3600
16+
17+
# MAIL CONFIGURATION
18+
MAIL_SERVER = 'smtp.gmail.com'
19+
MAIL_PORT = 465
20+
MAIL_USE_SSL = True
21+
MAIL_USE_TLS = False
22+
MAIL_USERNAME = 'username@gmail.com'
23+
MAIL_PASSWORD = 'password'
24+
MAIL_DEFAULT_SENDER = 'username@gmail.com'
25+
26+
# ADMIN PANEL
27+
FLASK_ADMIN_FLUID_LAYOUT = True
1128

1229
# SESSION_COOKIE_SECURE = True
1330
SESSION_COOKIE_HTTPONLY = True

lms/lmsweb/forms/register.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from flask_babel import gettext as _ # type: ignore
2+
from flask_wtf import FlaskForm
3+
from wtforms import PasswordField, StringField
4+
from wtforms.validators import Email, EqualTo, InputRequired, Length
5+
6+
from lms.lmsweb.tools.validators import (
7+
UniqueEmailRequired, UniqueUsernameRequired,
8+
)
9+
10+
11+
class RegisterForm(FlaskForm):
12+
email = StringField(
13+
'Email', validators=[
14+
InputRequired(), Email(message=_('אימייל לא תקין')),
15+
UniqueEmailRequired,
16+
],
17+
)
18+
username = StringField(
19+
'Username', validators=[
20+
InputRequired(), UniqueUsernameRequired, Length(min=4, max=20),
21+
],
22+
)
23+
fullname = StringField(
24+
'Full Name', validators=[InputRequired(), Length(min=3, max=60)],
25+
)
26+
password = PasswordField(
27+
'Password', validators=[InputRequired(), Length(min=8)], id='password',
28+
)
29+
confirm = PasswordField(
30+
'Password Confirmation', validators=[
31+
InputRequired(),
32+
EqualTo('password', message=_('הסיסמאות שהוקלדו אינן זהות')),
33+
],
34+
)

lms/lmsweb/tools/validators.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from flask_babel import gettext as _ # type: ignore
2+
from wtforms.fields.core import StringField
3+
from wtforms.validators import ValidationError
4+
5+
from lms.lmsdb.models import User
6+
7+
8+
def UniqueUsernameRequired(
9+
_form: 'RegisterForm', field: StringField, # type: ignore # NOQA: F821
10+
) -> None:
11+
username_exists = User.get_or_none(User.username == field.data)
12+
if username_exists:
13+
raise ValidationError(_('שם המשתמש כבר נמצא בשימוש'))
14+
15+
16+
def UniqueEmailRequired(
17+
_form: 'RegisterForm', field: StringField, # type: ignore # NOQA: F821
18+
) -> None:
19+
email_exists = User.get_or_none(User.mail_address == field.data)
20+
if email_exists:
21+
raise ValidationError(_('האימייל כבר נמצא בשימוש'))

lms/lmsweb/translations/en/LC_MESSAGES/messages.po

Lines changed: 100 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: lmsweb-1.0\n"
99
"Report-Msgid-Bugs-To: bugs@mesicka.com\n"
10-
"POT-Creation-Date: 2020-10-09 11:20+0300\n"
10+
"POT-Creation-Date: 2021-09-12 15:10+0300\n"
1111
"PO-Revision-Date: 2020-09-16 18:29+0300\n"
1212
"Last-Translator: Or Ronai\n"
1313
"Language: en\n"
@@ -16,9 +16,9 @@ msgstr ""
1616
"MIME-Version: 1.0\n"
1717
"Content-Type: text/plain; charset=utf-8\n"
1818
"Content-Transfer-Encoding: 8bit\n"
19-
"Generated-By: Babel 2.8.0\n"
19+
"Generated-By: Babel 2.9.1\n"
2020

21-
#: lmsdb/models.py:632
21+
#: lmsdb/models.py:698
2222
msgid "כישלון חמור"
2323
msgstr "Fatal error"
2424

@@ -45,26 +45,79 @@ msgstr "The automatic checker couldn't run your code."
4545
msgid "אחי, בדקת את הקוד שלך?"
4646
msgstr "Bro, did you check your code?"
4747

48+
#: lmsweb/views.py:122
49+
msgid "לא ניתן להירשם כעת"
50+
msgstr "Can not register now"
51+
52+
#: lmsweb/views.py:139
53+
msgid "ההרשמה בוצעה בהצלחה"
54+
msgstr "Registration successfully"
55+
56+
#: lmsweb/views.py:161
57+
msgid "קישור האימות פג תוקף, קישור חדש נשלח אל תיבת המייל שלך"
58+
msgstr "The confirmation link is expired, new link has been sent to your email"
59+
60+
#: lmsweb/views.py:174
61+
#, fuzzy
62+
msgid "המשתמש שלך אומת בהצלחה, כעת אתה יכול להתחבר למערכת"
63+
msgstr "Your user has been successfully confirmed, you can now login"
64+
65+
#: lmsweb/forms/register.py:14
66+
msgid "אימייל לא תקין"
67+
msgstr "Invalid email"
68+
69+
#: lmsweb/forms/register.py:32
70+
msgid "הסיסמאות שהוקלדו אינן זהות"
71+
msgstr "The passwords are not identical"
72+
4873
#: lmsweb/tools/registration.py:105
4974
msgid "מערכת הגשת התרגילים"
5075
msgstr "Exercuse submission system"
5176

52-
#: models/solutions.py:46
77+
#: lmsweb/tools/validators.py:13
78+
msgid "שם המשתמש כבר נמצא בשימוש"
79+
msgstr "The username already in use"
80+
81+
#: lmsweb/tools/validators.py:21
82+
msgid "האימייל כבר נמצא בשימוש"
83+
msgstr "The email already in use"
84+
85+
#: models/register.py:20
86+
#, python-format
87+
msgid "מייל אימות - %(site_name)s"
88+
msgstr "Confirmation mail - %(site_name)s"
89+
90+
#: models/register.py:25
91+
#, fuzzy, python-format
92+
msgid "שלום %(fullname)s,\nלינק האימות שלך למערכת הוא: %(link)s"
93+
msgstr "Hello %(fullname)s,\n Your confirmation link is: %(link)s"
94+
95+
#: models/solutions.py:50
5396
#, python-format
5497
msgid "%(solver)s הגיב לך על בדיקת תרגיל \"%(subject)s\"."
5598
msgstr "%(solver)s has replied for your \"%(subject)s\" check."
5699

57-
#: models/solutions.py:53
100+
#: models/solutions.py:57
58101
#, python-format
59102
msgid "%(checker)s הגיב לך על תרגיל \"%(subject)s\"."
60103
msgstr "%(checker)s replied for \"%(subject)s\"."
61104

62-
#: models/solutions.py:65
105+
#: models/solutions.py:69
63106
#, python-format
64107
msgid "הפתרון שלך לתרגיל \"%(subject)s\" נבדק."
65108
msgstr "Your solution for the \"%(subject)s\" exercise has been checked."
66109

67-
#: templates/banned.html:8 templates/login.html:7
110+
#: models/users.py:25
111+
#, fuzzy
112+
msgid "שם המשתמש או הסיסמה שהוזנו לא תקינים"
113+
msgstr "Invalid username or password"
114+
115+
#: models/users.py:27
116+
#, fuzzy
117+
msgid "עליך לאשר את מייל האימות"
118+
msgstr "You have to confirm your registration with the link sent to your email"
119+
120+
#: templates/banned.html:8 templates/login.html:7 templates/signup.html:8
68121
msgid "תמונת הפרופיל של קורס פייתון"
69122
msgstr "Profile picture of the Python Course"
70123

@@ -84,7 +137,7 @@ msgstr "Exercise submission system for the Python Course"
84137
msgid "תרגילים"
85138
msgstr "Exercises"
86139

87-
#: templates/exercises.html:21
140+
#: templates/exercises.html:21 templates/view.html:101
88141
msgid "הערות על התרגיל"
89142
msgstr "Comments for the solution"
90143

@@ -108,26 +161,30 @@ msgstr "All Exercises"
108161
msgid "התחברות"
109162
msgstr "Login"
110163

111-
#: templates/login.html:10
164+
#: templates/login.html:10 templates/signup.html:11
112165
msgid "ברוכים הבאים למערכת התרגילים!"
113166
msgstr "Welcome to the exercise system!"
114167

115168
#: templates/login.html:11
116169
msgid "הזינו את שם המשתמש והסיסמה שלכם:"
117170
msgstr "Insert your username and password:"
118171

119-
#: templates/login.html:15 templates/login.html:17
172+
#: templates/login.html:22 templates/login.html:24 templates/signup.html:16
120173
msgid "שם משתמש"
121174
msgstr "Username"
122175

123-
#: templates/login.html:21 templates/login.html:23
176+
#: templates/login.html:28 templates/login.html:30 templates/signup.html:18
124177
msgid "סיסמה"
125178
msgstr "Password"
126179

127-
#: templates/login.html:28
180+
#: templates/login.html:35
128181
msgid "התחבר"
129182
msgstr "Login"
130183

184+
#: templates/login.html:39 templates/signup.html:22
185+
msgid "הירשם"
186+
msgstr "Register"
187+
131188
#: templates/navbar.html:8
132189
msgid "הלוגו של פרויקט לומדים פייתון: נחש צהוב על רקע עיגול בצבע תכלת, ומתחתיו כתוב - לומדים פייתון."
133190
msgstr "The logo of the Learning Python project: yellow snake on light blue circle background and behind of it written - Learning Python"
@@ -164,6 +221,32 @@ msgstr "Check Exercises"
164221
msgid "התנתקות"
165222
msgstr "Logout"
166223

224+
#: templates/signup.html:9
225+
#, fuzzy
226+
msgid "הרשמה"
227+
msgstr "Registration"
228+
229+
#: templates/signup.html:12
230+
msgid "הזינו אימייל וסיסמה לצורך רישום למערכת:"
231+
msgstr "Insert your email and password for registration:"
232+
233+
#: templates/signup.html:15
234+
msgid "כתובת אימייל"
235+
msgstr "Email Address"
236+
237+
#: templates/signup.html:17
238+
msgid "שם מלא"
239+
msgstr "Full Name"
240+
241+
#: templates/signup.html:19
242+
#, fuzzy
243+
msgid "אימות סיסמה"
244+
msgstr "Password Confirmation"
245+
246+
#: templates/signup.html:25
247+
msgid "חזרה לדף ההתחברות"
248+
msgstr "Back to login page"
249+
167250
#: templates/status.html:7
168251
msgid "חמ\"ל תרגילים"
169252
msgstr "Exercises operations room"
@@ -256,23 +339,23 @@ msgstr "Submitted"
256339
msgid "לא הוגש"
257340
msgstr "Not submitted"
258341

259-
#: templates/user.html:43
342+
#: templates/user.html:44
260343
msgid "פתקיות:"
261344
msgstr "Notes:"
262345

263-
#: templates/user.html:60 templates/user.html:62
346+
#: templates/user.html:49 templates/user.html:51
264347
msgid "פתקית חדשה"
265348
msgstr "New Note"
266349

267-
#: templates/user.html:66
350+
#: templates/user.html:55
268351
msgid "תרגיל משויך:"
269352
msgstr "Exercise:"
270353

271-
#: templates/user.html:75
354+
#: templates/user.html:64
272355
msgid "רמת פרטיות:"
273356
msgstr "Privacy Level:"
274357

275-
#: templates/user.html:81
358+
#: templates/user.html:70
276359
msgid "הוסף פתקית"
277360
msgstr "Add Note"
278361

@@ -332,10 +415,6 @@ msgstr "Error:"
332415
msgid "שגיאת סגל:"
333416
msgstr "Staff Error:"
334417

335-
#: templates/view.html:101
336-
msgid "הערות על התרגיל"
337-
msgstr "Comments for the exercise"
338-
339418
#: templates/view.html:109
340419
msgid "הערות כלליות"
341420
msgstr "General comments"

0 commit comments

Comments
 (0)