Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CelcatSanitizer Teacher
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Léo Grange
CelcatSanitizer Teacher
Commits
77b6ade4
Commit
77b6ade4
authored
6 years ago
by
Alban Gruin
Browse files
Options
Downloads
Patches
Plain Diff
parsers: déplacement de delete_courses_in_week() vers timetable.py
Signed-off-by:
Alban Gruin
<
alban@pa1ch.fr
>
parent
e7f2ccdd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
management/commands/timetables.py
+9
-3
9 additions, 3 deletions
management/commands/timetables.py
management/parsers/ups2017.py
+1
-8
1 addition, 8 deletions
management/parsers/ups2017.py
with
10 additions
and
11 deletions
management/commands/timetables.py
+
9
−
3
View file @
77b6ade4
...
...
@@ -23,8 +23,14 @@
from
...models
import
Course
,
Source
from
...utils
import
get_week
,
tz_now
from
..parsers.ups2017
import
delete_courses_in_week
,
get_events
,
\
get_update_date
,
get_weeks
,
get_xml
from
..parsers.ups2017
import
get_events
,
get_update_date
,
get_weeks
,
\
get_source
def
delete_courses_in_week
(
source
,
year
,
week
,
today
):
start
,
end
=
get_week
(
year
,
week
)
Course
.
objects
.
filter
(
begin__gte
=
max
(
start
,
today
),
begin__lt
=
end
,
source
=
source
).
delete
()
@transaction.atomic
...
...
@@ -100,7 +106,7 @@ def process_timetable_week(source, soup, weeks_in_soup, force,
def
process_timetable
(
source
,
force
,
year
=
None
,
weeks
=
None
):
soup
=
get_
xml
(
source
.
url
)
soup
=
get_
source
(
source
.
url
)
weeks_in_soup
=
get_weeks
(
soup
)
if
year
is
not
None
and
weeks
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
management/parsers/ups2017.py
+
1
−
8
View file @
77b6ade4
...
...
@@ -20,7 +20,6 @@
from
django.utils
import
timezone
from
...models
import
Course
,
Group
,
Room
from
...utils
import
get_week
import
requests
import
edt
...
...
@@ -32,12 +31,6 @@ def add_time(date, time):
return
date
+
delta
def
delete_courses_in_week
(
source
,
year
,
week
,
today
):
start
,
end
=
get_week
(
year
,
week
)
Course
.
objects
.
filter
(
begin__gte
=
max
(
start
,
today
),
begin__lt
=
end
,
source
=
source
).
delete
()
def
get_event
(
source
,
event
,
event_week
,
today
):
"""
Renvoie une classe Course à partir d’un événement récupéré par BS4
"""
# On récupère la date de l’évènement à partir de la semaine
...
...
@@ -155,7 +148,7 @@ def get_weeks(soup):
return
weeks
def
get_
xml
(
url
):
def
get_
source
(
url
):
user_agent
=
"
celcatsanitizer/
"
+
edt
.
VERSION
req
=
requests
.
get
(
url
,
headers
=
{
"
User-Agent
"
:
user_agent
})
req
.
encoding
=
"
utf8
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment