Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit fb8f2a6

Browse files
authored
Merge pull request #2050 from bjones1/next
rsmanage studentinfo fixes/improvements
2 parents 3d414f9 + 23162a1 commit fb8f2a6

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

rsmanage/rsmanage.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -827,22 +827,28 @@ def studentinfo(config, student):
827827
student = click.prompt("Student Id: ")
828828

829829
res = eng.execute(
830+
## Index 0 1 2 3 4 5 6
830831
f"""
831-
select auth_user.id, first_name, last_name, email, courses.course_name, courses.id
832-
from auth_user join user_courses ON user_courses.user_id = auth_user.id
832+
select auth_user.id, first_name, last_name, email, courses.course_name, courses.id, payments.charge_id
833+
from auth_user
834+
join user_courses on user_courses.user_id = auth_user.id
835+
full outer join payments on user_courses.id = payments.user_courses_id
833836
join courses on courses.id = user_courses.course_id where username = '{student}'"""
834837
)
835838
# fetchone fetches the first row without closing the cursor.
836839
first = res.fetchone()
837-
print("id\tFirst\tLast\temail")
838-
print("\t".join(str(x) for x in first[:4]))
839-
print("")
840-
print(" Course cid")
841-
print("--------------------------")
842-
print(f"{first[-2].rjust(15)} {str(first[-1]).rjust(10)}")
843-
if res:
840+
if first:
841+
print("id\tFirst\tLast\temail")
842+
print("\t".join(str(x) for x in first[:4]))
843+
print("")
844+
print("Course cid")
845+
print("----------------------------------- ----------")
846+
print(f"{first[4].ljust(35)} {str(first[5]).rjust(10)} {first[6] if first[6] is not None else ''}")
844847
for row in res:
845-
print(f"{row[-2].rjust(15)} {str(row[-1]).rjust(10)}")
848+
print(f"{row[4].ljust(35)} {str(row[5]).rjust(10)} {row[6] if row[6] is not None else ''}")
849+
print("\n")
850+
else:
851+
print("Student not found.")
846852

847853

848854
@cli.command()

0 commit comments

Comments
 (0)